You are on page 1of 21

Ali Alhamaly

201406980
ME 505: Assignment 1
Problem 1:
Write the generalized transport equation in conservative form and non-conservative form (in
Vector notation) and show that both forms are equivalent.
The generalized transport equation for a conserved quantity in conservative form is given by:

+ . () = . ( ) +

(1)

To write Eq. (1) in non-conservative from, we need to expand the derivative in the LHS of Eq. (1):

+
+ . () + (. ) = . ( ) +

(2)

By collecting the terms in Eq. (2) we get:


(

+ . ()) + ( + (. )) = . ( ) +

(3)

The continuity equation (setting = 1 with = 0 in Eq. (1)) is:

+ . ()) = 0

(4)

+ (. )) = . ( ) +

(5)

(
Using Eq. (4) in Eq. (3) gives:
(
identifying that

+ (. ) =

gives:
1

= . ( ) +

(6)

Equation (6) is the generalized transport equation in non-conservative form.

Problem 2:
Fill the table for the generalized conservation equation as discussed in lecture 3.
Quantity
Mass
x-Momentum

y-Momentum

z-Momentum

Enthalpy

Temperature

Species mass
fraction

Symbol

0
.
)

(
+ ( + )

.
)

(
+
+ ( + )

.
)

(
+
+ ( + )

+ +

( +
) /

Meaning
Dynamic viscosity
Volumetric body force

Bulk viscosity

Thermal conductivity

Specific heat

Density

Viscous dissipation

Volumetric heat generation

Mass diffusion coefficient for specie i

Rate of generation of specie i


2

Problem 3:
We like to solve the 1D heat conduction using 3 methods for the following 2 problems:
Case 1: A flat plate of thickness L=2cm, k=0.5W/(mK) and heat generation of 1000 kW/m3.
The plate is maintained between Tleft=100C and Tright of 200C.
Case 2: A circular fin of constant cross-sectional area A, perimeter P, thermal conductivity k,
heat transfer coefficient h and length L=1m. The fin base temperature is TB=100C and the other
tip is insulated. The ambient temperature is 20C, and hP/(kA)=25m-2.

Solution Methods:
1. Exact
2. Finite Volume with cell length i) L/5, ii) L/10 and iii) L/50
3. Finite difference method with node spacing of i) L/5, ii) L/10 and iii) L/50
For both FV and FD use direct solution method (Matrix inversion) and iterative method (e.g. Gauss
Sidel)
Deliverable
a) Please show your derivation of the discretized equation for Finite volume and finite
difference for a typical finite volume (or typical node) and for boundary nodes if needed.
b) Compare the temperature results for exact, FV (3 grids, direct, iterative) and FD (3 grids,
direct, iterative). Use tables and plots and indicate % difference
c) Do the same for the heat fluxes.
d) Compare the time of execution between 2iii) and 3iii) and the matrix inversion part. (If small
difference in time, use L/100.)
e) Discuss your results briefly.

Case 1:
Part a)
Derivation of the discretized equation for finite volume:
The governing equation is:

( ) =

(7)

Typical finite volume discretized equation:

Integrating Eq.(7) along the volume P (see Fig. 1) and using the divergence theorem to convert
the volume integral of the LHS of Eq.(7) to surface integral gives:

e
P

Fig. 1schematic of typical cell volume

) | ( ) | =

(8)

Where is the average of over the volume, and is the area of the volume cell faces.
Approximating the derivatives at faces e and w by central difference approximation gives:

(
Using =



) (
) =

(9)

and rearranging, Eq. (9) becomes:


( + ) =

(10)

= . Eq. (10) can be written as:

(11)

= + = , =
Finite volume left boundary discretized equation:
Integrating Eq.(7) along the volume P (see Fig. 2) and discretizing gives:

e
B

/2

Fig. 2 schematic of left boundary



) (
) =

/2

(12)

Equation (12) can be written as:


=

(13)

= + , = , = + , = 2
Finite volume right boundary discretized equation:

The discretized equation are the same as Eq. (13) with the coefficients being:

= + , = , = + , = 2

Derivation of the discretized equation for finite differences:


Typical node discretized equation:

Discretizing the second derivative in the LHS of Eq.(7) with central difference approximation
yields (see Fig. 3)

i-1

i+1

Fig. 3 schematic of typical node for finite differences

(1 + 2 +1 )
()2

= = 1 + 2 +1 =
()2

(14)

Left boundary discretized equation:


Discretizing the second derivative in the LHS of Eq.(7) at the left boundary (see Fig. 4)

Fig. 4 schematic of left boundary node for finite differences

()2
22 3 =
+ 1

(15)

Right boundary discretized equation:


Similar to Eq. (15) we get:
21 2
Where is the total number of nodes.

()2
=
+

(16)

Part b)
The exact solution of Eq.(7) is:

( ) =

2 2
2
+ (( ) +
) +
2
2

(17)

Where = /.
For finite volume method, the temperature was solved at the locations:
1

= [0 ,

3
2

(21)
2

, ] for = [5 , 10 , 50] and = [5, 10, 50]

For finite differences method, the temperature was solved at the locations:
1

= [0 , ,2 ( 2) , ] for = [5 , 10 , 50] and = [6, 11, 51]


The error of the solution is given by:
(%) =

| |
100

(18)

Figures 5 and Error! Reference source not found. and Table 1 and Table 2 show comparison
between the finite volume and finite differences solutions with the exact solution. Note that in Fig.
5 and Error! Reference source not found. only direct method solution are shown. This is because
the difference between the direct method and iterative method

a)

is

b)

extremely small which makes the lines on top of each other.

Fig. 5 Comparison of temperature results for finite volume method using multiple cell sizes. a)
Temperature distribution b) error percentage compared with exact solution
7

Table 1. Comparison between the exact and finite volume method for different cell sizes.

0.1
0.5
0.9

146
250
226

0.05
0.45
0.85

124
244
236

0.01
0.35
0.69

104.96
226.00
254.56

= /5

150
254
230

149.9999969
253.9999937
229.9999986

= /10

125
245
237

124.9999946
244.9999727
236.9999897

= /50

105.00
226.04
254.60

104.9999765
226.0393554
254.5994214

2.7397260
1.6000000
1.7699115

0.806451613
0.409836066
0.423728814

0.038109756
0.017699115
0.015713388

2.7397239
1.5999975
1.7699109

0.806447265
0.40982489
0.423724441

0.038087346
0.017413908
0.015486107

a)

b)
Fig. 6 Comparison of temperature results for finite differences method using multiple node
spacing. a) Temperature distribution b) error percentage compared with exact solution
8

Table 2. Comparison between the exact and finite differences method for different node
spacing.

0.2
0.6
0.8

184
256
244

0.1
0.4
0.9

146
236
226

0.02
0.36
0.98

109.84
228.16
205.84

= /5

184
256
244

183.9999969
255.9999967
243.9999983

= /10

146
236
226

145.9999909
235.9999759
225.9999939

= /50

109.84
228.16
205.84

109.8399535
228.1593524
205.8399577

0
1.11E-14
0

0
2.41E-14
0

1.04E-13
7.47E-13
6.90E-14

1.71E-06
1.30E-06
6.84E-07

6.23E-06
1.02E-05
2.69E-06

4.23E-05
0.000283853
2.05E-05

Part c)
The exact heat flux is given by:
( )

(19)
= = (
+ )

2
For finite volume method, the flux was obtained using central difference approximation to
approximate the temperature derivative (except at the boundaries in which forward or backward
differences is used as appropriate). The locations of the approximate flux is at:

= [0 , ,2 ( 1) , ] for = [5 , 10 , 50] and = [5, 10, 50]


For finite differences method, the flux was obtained using central difference approximation to
approximate the temperature derivative (except at the boundaries in which forward or backward
differences is used as appropriate). The locations of the approximate flux is at:
1

= [0 , ,2 ( 2) , ] for = [5 , 10 , 50 , 100] and = [6, 11, 51]

Figures 7 and Table 3 and 4 show comparison between the finite volume and finite differences
flux solutions with the exact flux solution.

a)

b)
Fig. 7 Comparison of flux results for finite volume method using multiple cell sizes. a) flux
distribution b) error percentage compared with exact solution

Table 3. Comparison between the exact and finite volume method for different cell sizes.

0
0.4
0.8

-12500
-4500
3500

0
0.3
0.6

-12500
-6500
-500

0
0.34
0.68

-12500
-5700
1100

= /5

-12500
-4500
3500

-12499.9992
-4500.00000
3499.99965

= /10

-12500
-6500
-500

-12499.9973
-6499.99893
-500.000916

= /50

-12500
-5700
1100

-12499.9412
-5699.97417
1099.969079

0
0
2.08E-13

0
-1.12E-13
0

-5.68E-13
-5.58E-13
6.82E-13

-6.28E-06
0
9.97E-06

-2.16E-05
-1.64E-05
-0.00018

-0.00047
-0.00045
0.002811

10

Fig. 8 Comparison of flux results for finite differences method using multiple node spacing. a)
flux distribution b) error percentage compared with exact solution

Table 4. Comparison between the exact and finite differences method for different node
spacing.

0
0.4
1

-12500
-4500
7500

0
0.3
1

-12500
-6500
7500

0
0.34
1

-12500
-5700
7500

= /5

-10500
-4500
5500

-10500
-4500
5500

= /10

-11500
-6500
6500

-11500
-6500
6499.998

= /50

-12300
-5700
7300

-12299.9
-5699.97
7299.947

-16
-4.04E-14
26.66667

-8
-1.12E-13
13.33333

-1.6
-1.80E-12
2.666667

-16
-2.58E-07
26.66667

-8.00002
-1.47E-05
13.33335

-1.60046
-0.00045
2.667371

11

Part d)
Figure 9 Comparison of time of execution between finite volume and finite differences shows
comparison between time of execution of finite volume and finite differences using direct
inversion method.

Fig. 9 Comparison of time of execution between finite volume and finite differences

Part e)
Finite volume method gives accurate results for the temperature distribution even with only 5
volume cells. As can be seen in Fig. 5, the error is less than 3%. Table 1 show that the direct and
iterative methods of solution given essentially same results. Finite differences is more accurate
than finite volume for this problem as can be seen by comparing Fig. 5 and Fig. 6. For heat flux
values, both finite volume and finite differences are very accurate. However, the boundary flux for
the finite differences has substation error probably because of first order derivative approximation
that is used for calculation. In terms of computational cost, Fig. 9 shows that finite differences is
little bit more costly compared with finite volume. In general, an order of magnitude increase in
the size of the system gives order of magnitude increase in terms of computation time.

12

Case 2:
Part a)
Derivation of the discretized equation for finite volume:
The governing equation is:

( ) =

= ,

(20)
=

Typical finite volume discretized equation:

Integrating Eq.(20) along the volume P (see Fig. 1) and using the divergence theorem to convert
the volume integral of the LHS of Eq.(20) to surface integral gives:

) | ( ) | =

(21)

Where is the average of over the volume, and is the area of the volume cell faces.
Approximating the derivatives at faces e and w by central difference approximation gives:

(
Using =



) (
) =

and rearranging, Eq. (22) becomes:


( + ) =

1 +



Evaluating the integral in Eq. (24) using trapezoidal approximation gives:
=

=
+
2

(22)

+
2

(23)

(24)

(25)

= (by linear interpolation). Hence:

13

(26)
=

In general, we would like to write = + . So for typical cell volume, we have:

= , = 0 . Eq. (23) can be written as:


=

(27)

= + = , =
Finite volume left boundary discretized equation:
Integrating Eq.(20) along the volume P (see Fig. 2) and discretizing gives:



) (
) =

/2

(28)

Equation (12) can be written as:


=

(29)

= , = , = = , = 2
Finite volume right boundary discretized equation:
The discretized equation are the same as Eq.(29) with the coefficients being:
= , = , = = 0
Note that the right boundary value = where N is the last cell volume. This due to the zero
flux boundary condition at the right boundary.
Derivation of the discretized equation for finite differences:
Typical node discretized equation:
Discretizing the second derivative in the LHS of Eq.(20) with central difference approximation
yields (see Fig. 3)
14

(1 2 + +1 )
= 0 = 1 + (2 + 2 ) +1 = 0
()2

(30)

Left boundary discretized equation:


Discretizing the second derivative in the LHS of Eq.(20) at the left boundary (see Fig. 4)
(2 + 2 )2 3 = 1

(31)

Right boundary discretized equation:


the second derivative in the LHS of Eq.(20) is discretized using backward difference as follows:

|
= =/2
/2

|
= 0, |=/2 =
=

(32)

( 1 )

|=
|

=/2 = 2( 1 )
/2
2

(33)

Using Eq. (33), the discretized from of Eq.(20) becomes:


(2 + 2 ) 21 = 0

(34)

Where is the total number of nodes.

Part b)
The exact solution of Eq.(20) is:

( )

cosh ((1 ))
cosh()

(35)

15

Where = /.
For finite volume method, the temperature was solved at the locations:
1

= [0 ,

3
2

(21)
2

, ] for = [5 , 10 , 50] and = [5, 10, 50]

For finite differences method, the temperature was solved at the locations:
1

= [0 , ,2 ( 2) , ] for = [5 , 10 , 50] and = [6, 11, 51]


The error of the solution is given by:
(%) =

| |
100

(36)

Figures 10 and 11 and Tables 5 and 6 show comparison between the finite volume and finite
differences solutions with the exact solution.

Fig. 10 Comparison of temperature results for finite volume method using multiple cell sizes. a)
Temperature distribution b) error percentage compared with exact solution

16

Table 5. Comparison between the exact and finite volume method for different cell sizes.

0.1
0.5
0.9

0.05
0.45
0.85

62.3059
8.466013
1.395698

0.01
0.35
0.69

48.52624
6.610747
1.215606

76.09872
13.92218
2.65394

= /5

44.22764
6.504065
1.300813

44.22764
6.504066
1.300813

= /10

60.5991
8.404587
1.417561

60.5991
8.404595
1.417566

= /50

76.00535
13.915
2.654584

76.00536
13.91515
2.654807

8.858291
1.613758
7.009404

2.739384
0.725558
1.566481

0.122686
0.051608
0.024294

8.858289
1.613741
7.009434

2.739381
0.725465
1.566856

0.122679
0.05053
0.032697

Fig. 11 Comparison of temperature results for finite differences method using multiple node
spacing. a) Temperature distribution b) error percentage compared with exact solution

17

Table 6. Comparison between the exact and finite differences method for different node
spacing

0.2
0.6
0.8

29.43889
4.055732
1.663476

0.1
0.4
0.9

48.52624
10.85317
1.215606

0.02
0.36
0.98

72.38772
13.24528
1.083417

= /5

30.56911
4.552846
1.95122

30.56911
4.552847
1.951221

= /10

48.77309
11.07705
1.275805

48.77309
11.07706
1.275812

= /50

72.39074
13.25526
1.085669

72.39075
13.25541
1.085905

3.839187
12.25706
17.29774

0.508691
2.062835
4.952162

0.004166
0.075368
0.207881

3.839192
12.2571
17.29781

0.508698
2.06291
4.952745

0.004179
0.076498
0.229631

Part c)
The exact heat flux is given by:
sinh ((1 ))
1

= =

cosh()

(37)

For finite volume method, the flux was obtained using central difference approximation to
approximate the temperature derivative (except at the left boundary in which forward differences
is used). The locations of the approximate flux is at:
1

= [0 , ,2 ( 1) , ] for = [5 , 10 , 50] and = [5, 10, 50]


For finite differences method, the flux was obtained using central difference approximation to
approximate the temperature derivative (except at the left boundary in which forward differences
is used). The locations of the approximate flux is at:
1

= [0 , ,2 ( 2) , ] for = [5 , 10 , 50] and = [6, 11, 51]


Figures 12 and 13 and Tables 7 and 8 show comparison between the finite volume and finite
differences flux solutions with the exact flux solution.

18

Fig. 12 Comparison of flux results for finite volume method using multiple cell sizes. a) flux
distribution b) error percentage compared with exact solution
Table 7. Comparison between the exact and finite volume method for different cell sizes.

0
0.4
0.8

399.9637
53.99748
6.334467

0
0.3
0.6

399.9637
89.16663
19.54919

0
0.34
0.68

399.9637
72.97069
12.80458

= /5

357.7236
52.03252
6.504065

357.7236
52.03252
6.504067

= /10

388.018
87.82304
19.53576

388.018
87.82303
19.53577

= /50

399.4645
72.93094
12.80599

399.464
72.9306
12.80589

10.56099
3.638978
2.677383

2.986689
1.506834
0.06866

0.124804
0.054469
0.010982

10.56099
3.638976
2.677412

2.986699
1.506846
0.06863

0.12493
0.054935
0.010219

19

Fig. 13 Comparison of flux results for finite differences method using multiple node spacing. a)
flux distribution b) error percentage compared with exact solution

Table 8. Comparison between the exact and finite differences method for different node
spacing.

0
0.4
0.8

399.9637
53.99748
6.334467

0
0.3
0.9

399.9637
89.16663
2.808763

0
0.34
0.98

399.9637
72.97069
0.53991

= /5

247.1545
65.04065
8.130081

247.1545
65.04065
8.130083

= /10

312.2691
93.31197
3.012317

312.2691
93.31196
3.012325

= /50

380.4632
73.11327
0.541484

380.4627
73.11293
0.541537

38.20577
20.45128
28.34673

21.92563
4.648989
7.247139

4.87557
0.195395
0.291582

38.20577
20.45128
28.34676

21.92564
4.648974
7.247402

4.87569
0.194928
0.301383

20

Part d)
Figure 14 shows comparison between time of execution of finite volume and finite differences
using direct inversion method.

Fig. 14 Comparison of time of execution between finite volume and finite differences

Part e)
Both finite volume and finite differences method give reasonable accurate results for the
temperature distribution. The accuracy increases quickly with the number of cells and with the
decrease in number of nodes. Generally Case 2 accuracy is less than Case1 for the same cell
numbers. The same trends goes for heat flux values with the finite volume being more accurate
than finite differences. Errors in heat flux are maximum at the left boundary for both finite volume
and finite differences. In terms of computational cost, Fig. 14 shows that finite differences is an
order of magnitude slower compared with finite volume. This is in contrast with Case 1 in which
both finite volume and finite differences have essentially the same time of execution.

21

You might also like