You are on page 1of 62

Temperature response of a slab with negligible surface resistance

Finite differences, explicite method. Solved in Visual basic [1]


Input of independent variables
tinitial = 0 s initial time
x1 = -0.1 m starting distance
x2 = 0.1 m ending distance
a = 1.1E-05 m²/s thermal diffusivity
tfinal= 180 s final time
nDx = 20 - number of elements
- Procedure:
- Cleat output range
- Set the initial boundary conditions. Define function F
- Set temperaturers at the surfaces. Define functions P and Q
- Run the program Change Initial or
Run Finite Difference Clear Output
Boundary
Program Range
Conditions
0 1 2 3 4 5

Slab temperature (U) as function of position (x) and time (t)


x [m] U(x) U(x) U(x) U(x) U(x) U(x)
time [s] 0 36 73 108 144 180 Eq. 1
1 -0.1 0.0 0.0 0.0 0.0 0.0 0.0
2 -0.09 100.0 27.4 19.6 16.2 14.0 12.5
3 -0.08 100.0 51.6 38.1 31.8 27.6 24.6
4 -0.07 100.0 70.6 54.4 46.1 40.3 36.0
5 -0.06 100.0 83.8 68.0 58.6 51.7 46.5
6 -0.05 100.0 92.0 78.6 69.2 61.7 55.7
7 -0.04 100.0 96.4 86.4 77.7 69.9 63.4
8 -0.03 100.0 98.6 91.7 84.1 76.4 69.6
9 -0.02 100.0 99.5 95.1 88.5 81.0 74.1
10 -0.01 100.0 99.8 96.9 91.0 83.8 76.8
11 0 100.0 99.9 97.4 91.9 84.7 77.7
12 0.01 100.0 99.8 96.9 91.0 83.8 76.8
13 0.02 100.0 99.5 95.1 88.5 81.0 74.1
14 0.03 100.0 98.6 91.7 84.1 76.4 69.6
15 0.04 100.0 96.4 86.4 77.7 69.9 63.4
16 0.05 100.0 92.0 78.6 69.2 61.7 55.7
17 0.06 100.0 83.8 68.0 58.6 51.7 46.5
18 0.07 100.0 70.6 54.4 46.1 40.3 36.0
19 0.08 100.0 51.6 38.1 31.8 27.6 24.6
20 0.09 100.0 27.4 19.6 16.2 14.0 12.5
21 0.1 0.0 0.0 0.0 0.0 0.0 0.0

iterations: 119
Comparison of the solutions using finite differences
and the analytical solution

Slab characteristic length


Wslab = x2 - x1 Required is the temperat
x1 = -0.1 m x=
x 2= 0.1 m after a time
Wslab = 0.2 m Slab width t=
L= Wslab / 2 Halb slab width
L= 0.10 m From the table
T=
Initial slab temperature
Initially, the slab has a temperature defined
by the function F
T(x, t=0) = F(x)
To apply the analytic solution, a slab with a uniform
initial temperature T0 is used.
Let
T0 = F(x) = 100 ºC

Surface temperature Ts at time 0+


Defined with functions P and Q
Let:
Function P(t) To be considered
boundary condition at x = x1
P= 0 ºC The finite difference solu
Function Q(t) within the values x = 0 t
boundary condition at x = x2 Ther nalytical solution co
Q= 0 ºC the values x = 0 (at the m

For the comparison, che


Problem description Input definitions in the code:
A slab is initially at a temperature defined by Set the initial temperaturer ditributions. Define function F
a temperature function F (to be defined in the code) For example, define a sinusoidal temperature distribution
At the initial time tinitial the surface temperatures F = 100 * Sin(pi / 2 * (1 + 10 * x))
are defined by the temperature functions P and Q, Set the temperatures at the surfaces. Define functions P
(also to be defined in the code). and Q. Example, set both surface temperatures equal 0:
The slab thicknes is Wslab = x2 - x1 Boundary condition at x = x1, insert function P = 0
The slab thermal difussivity is Alpha. Boundary condition at x = x2, insert function Q = 0
Required is the temperature distribution in the slab
from tinitial to tfinal.
Solve using a number of elements nDx.

Dependent variables
These values are calculated in the VB program
Wslab = x2 - x1 = 0.2 m Slab width
Dx = (Wslab) / nDx = 0.01 m distance interval
tstep = Dx^2 / (6*a) = 1.515 s time step to obtain Fo = 1/6
Fo = a*tstep/Dx^2 = 0.167 - must be <0.5 to be stable
nDtstep = (tfinal - tinitial) / t step = 118.8 - number of time intervals

Eq, (1) t = tinitial + tstep * i * nDtstep / 5 (for n = 0 to 5)


Columns for times 0 (s) to 180 (s) are outputs from code
Column for time = 0 (s), corresponds to the initial condition defined by the function F
Column for time = 37 (s), contains the values for t = f(x, 37)
Column for time = 72 (s), contains the values for t = f(x, 72) and so on.

Main finite difference equation [2]

T im+1 =T im+ Fo⋅(T im+1 -2⋅T im+T im-1 ) ( 3 . 107a )


' U(i) = V(i) + Fo * (V(i + 1) - 2 * V(i) + V(i - 1))
Temperature at a time "tau" and at a position "x" (using VBA function)
Tadim = Tadim_Alpha_L_tau_x T= Ts + Tadim * (Tini -Ts)
Alpha = 1.10E-05 Tini = 100 ºC
L= 0.1 Ts = 0 ºC
tau = 36.4 s T= #VALUE! ºC
x= 0.060 m According Ref 1:
Tadim = #VALUE! T= 83.8 ºC
F= 100 * sin(pi * x/W)
W= 0.1

x F
-0.1 0
-0.08 -59
-0.06 -95
-0.04 -95
-0.02 -59
0 0
0.02 59
0.04 95
0.06 95
0.08 59
0.1 0
Required is the temperature at a position:
0.05 m from mid plane
after a time
10

From the table


78.61 ºC

To be considered

The finite difference solution consideres a distance varying in the slab


within the values x = 0 to x = total width of slab
Ther nalytical solution consideres a distance varying in the slab, within
the values x = 0 (at the midplane) and x = L (L: halb slab width)

For the comparison, check that both cases have the same input values.

For the comparison, check that both cases


er ditributions. Define function F Slab with an initial temperature distribution defined with function F
nusoidal temperature distribution and surface temperatures at tau = 0+ defined with functions P & Q
(Case of a convection coefficient h ->infinite )
the surfaces. Define functions P
120
h surface temperatures equal 0:

U(x,t)
= x1, insert function P = 0 100
= x2, insert function Q = 0
80

60

40

20

0
-0.1 -0.08 -0.06 -0.04 -0.02 0 0.02 0.04 0.06 0.08 0.1
Distance x [m]

Iniial temperature distribution:


Function F: T= 100 ºC
If the initial temperature distribution is not a numeric value,
a zero value will be shown.

Surface temperatures
Function P: Ts-0.1 = 0 ºC
Function Q: Ts+0.1 = 0 ºC

Do not change the location of the cells in the input range (those shaded in yellow).
The VB program looks in those cells for the appropriate values.
Input to yellow shaded cells.
If Fo is greater than 0.5, either use a smaller time step or fewer distance intervals.
When using the proposed time step, the value of the Fourier number has a fixed value
of Fo = 1/6

Note. This spreadsheet is based on a file by Jeff Munic [1]


Dimensionless temperature. Analytical sol.
Tadim = Tadim_Alpha_L_tau_x
Alpha = 1.88E-03 m²/s
L= 0.1 m
tau = 10.00 s
x= 0.05 m
Tadim = #VALUE!

Temperature T
Tadim = (Ts - T) / (Ts - T0)
Ts - T = Tadim * (Ts -T0)
T= Ts - Tadim * (Ts -T0)

Ts: Surface temperature at a time 0+


Ts = 0 ºC
T0: Initial unifrom slab temperature
T= 100 ºC

Solution using the analytical method


T= #VALUE! ºC
at
t= 10 s
and at a distance
x' = 0.05 m
from mid plane

Solution using the finite differences method


T= 61.66 ºC

parison, check that both cases have the same input values.
defined with function F
with functions P & Q
)
0
36
73
10
8
14
4

04 0.06 0.08 0.1

(those shaded in yellow).


or fewer distance intervals.
rier number has a fixed value
Temperature response of a slab [2]

Analytic solution
A slab is initially at uniform temperature T ini .
At time t = 0, it is inmersed in a fluid at temperature T s.
The thermal diffusivity is Alpha and the half thickness
is L.

Tini = 100 ºC
Ts = 0 ºC
Alpha = 1.10E-05 m²/s
L= 0.1 m

Required are the dimensonless temperature


and the temperature of the slab

Considering the case of an infinite value of the


convection coefficient, the dimensionless temperature
is given by equation (3.44), [2], page 151.

Application of the VB function for a point at a


distance x from the midplane, after a time tau
Tadim = Tadim_Alpha_L_tau_x
Alpha = 1.10E-05 m²/s
L= 1.00E-01 m
tau = 300 s
x= 0.060 m
Tadim = #VALUE!

For
Tini = 100 ºC
Ts = 0 ºC
Tadim = (T - Ts) / (Tini - Ts)
T - Ts = Tadim * (Tini -Ts)
T= Ts + Tadim * (Tini -Ts)

Evaluation at point whith location


x= 0.06 m
at a time
t= 36 s

Tadim = Tadim_Alpha_L_tau_x
Alpha = 1.10E-05 m²/s
L= 0.1 m
tau = 36 s
x= 0.06 m
Tadim = #VALUE! -

T= Ts + Tadim * (Tini -Ts)


Ts = 0 ºC
Tadim = #VALUE!
Tini = 100 ºC
T= #VALUE! ºC

Temperature response of a slab

A slab is initially at uniform temperature T 0 .


At time t = 0, it is inmersed in a fluid at temperature T s.

Considering the case of an infinite value of the


convection coefficient, the dimensionless temperature
is given by equation (3.44), [1], page 151.
Required is the tempeature response of the slab.
Temperature response of a slab
Dimensionless temperature, according equation (3 . 44 ), [1 ] page
n
T-T s ∞
2⋅( -1 ) −( n+1/2 )2⋅π 2⋅Fo
=∑ ⋅e ⋅cos ( ( n+1/2 ) ⋅π⋅( x /L )) (3
T 0 -T s n = 0 ( n+1/2 )⋅π
where Fo is the Fourier number
α⋅τ
Fo= 2
L
α :thermal diffusivity ( m2 /s )
τ :time ( s)
L:half thickness of slab ( m)
T s : surface temperature for τ (0+) ( K )
T 0 : initial slab temperature (K )

=
n
T-T s ∞
2⋅( -1 ) −(n+1/2)2⋅π 2⋅Fo
Dimensionless temperature of a slab according equation (3.44) [2] =∑ ⋅e ⋅cos ( ( n+1
T 0 -T s n = 0 ( n+1/2 )⋅π
Dimensionless temperature
tau Distance x [m]
s -0.1 -0.09 -0.08 -0.07 -0.06 -0.05 -0.04 -0.03 -0.02 -0.01 0 0.01 0.02 0.03
9.0 ### ### ### ### ### ### ### ### ### ### ### ### ### ###
45.0 ### ### ### ### ### ### ### ### ### ### ### ### ### ###
73.0 ### ### ### ### ### ### ### ### ### ### ### ### ### ###

120.0 ### ### ### ### ### ### ### ### ### ### ### ### ### ###

200.0 ### ### ### ### ### ### ### ### ### ### ### ### ### ###
300.0 ### ### ### ### ### ### ### ### ### ### ### ### ### ###
400.0 ### ### ### ### ### ### ### ### ### ### ### ### ### ###
600.0 ### ### ### ### ### ### ### ### ### ### ### ### ### ###
900.0 ### ### ### ### ### ### ### ### ### ### ### ### ### ###

12.0 Dimensionless temperature

10.0 tau =9 (s)


Tadim (-)

tau = 45 (s)

8.0 tau = 90 (s)

tau = 120 (s)


6.0 tau = 200 (s)

tau = 300 (s)


4.0 tau = 400 (s)

tau = 600 (s)


2.0
tau = 900 (s)

0.0
-0.1 -0.08 -0.06 -0.04 -0.02
Distance x from0midplane (m) 0.02 0.04

Temperature
tau Distance x [m]
s -0.1 -0.09 -0.08 -0.07 -0.06 -0.05 -0.04 -0.03 -0.02 -0.01 0 0.01 0.02 0.03
0.1 ### ### ### ### ### ### ### ### ### ### ### ### ### ###

1.0 ### ### ### ### ### ### ### ### ### ### ### ### ### ###

5.0 ### ### ### ### ### ### ### ### ### ### ### ### ### ###

10.0 ### ### ### ### ### ### ### ### ### ### ### ### ### ###
20.0 ### ### ### ### ### ### ### ### ### ### ### ### ### ###
30.0 ### ### ### ### ### ### ### ### ### ### ### ### ### ###
36.0 ### ### ### ### ### ### ### ### ### ### ### ### ### ###
50.0 ### ### ### ### ### ### ### ### ### ### ### ### ### ###
60.0 ### ### ### ### ### ### ### ### ### ### ### ### ### ###

Location Temperature as function of the distance x, with the time tau as para
Temperature
120.0 x t x T
m ºC m s
100.0 0.06 0.0 -0.10 ###
0.06 10.0 -0.08 ###
80.0
0.06 20.0 -0.06 ###
0.06 30.0 -0.04 ###
60.0
0.06 40.0 -0.02 ###
40.0 0.06 50.0 0.00 ###
0.06 60.0 0.02 ###
20.0
0.06 70.0 0.04 ###
0.06 80.0 0.06 ###
0.0
-0.1 0.06 -0.08
90.0 -0.06 0.08 -0.04
tau = 0.1###
(s) tau = 1-0.02
(s) tau = 50 (s) 0.02
tau = 10 (s) 0.04
tau = 2
0.06 100 tau
0.10= 30 (s)
### tau = 36 (s) tau = 50 (s) tau = 60 (s) x
T

Fourier number
Fo = a * tau/L²
tau = Fo * L²/a (s)
(3 . 44 ), [1 ] page 151 Tadim = (T - Ts) / (Tini - Ts)

Eq. (3.44) [1], page 151


/2 ) ⋅π⋅( x /L )) (3. 44 ) Tadim = Sum (A * B * C) from n = 0 to infinity
A = 2 * (-1) ^ n / ((n + 1 / 2) * pi)
B = Exp(-(n + 1 / 2) ^ 2 * pi ^ 2 * Fo)
C = Cos((n + 1 / 2) * pi * (x / L))

T - Ts =

Microsoft Equation
3.0
n page 1 of 3
2⋅( -1 ) −(n+1/2)2⋅π 2⋅Fo
⋅e ⋅cos ( ( n+1/2 ) ⋅π⋅( x/L )) (3. 44)
+1/2 )⋅π

0.04 0.05 0.06 0.07 0.08 0.09 0.1


### ### ### ### ### ### ###

### ### ### ### ### ### ###

### ### ### ### ### ### ###

### ### ### ### ### ### ###

### ### ### ### ### ### ###

### ### ### ### ### ### ###

### ### ### ### ### ### ###

### ### ### ### ### ### ###

### ### ### ### ### ### ###

02 0.04 0.06 0.08 0.1

page 2 of 3

0.04 0.05 0.06 0.07 0.08 0.09 0.1


### ### ### ### ### ### ###

### ### ### ### ### ### ###

### ### ### ### ### ### ###

### ### ### ### ### ### ###

### ### ### ### ### ### ###

### ### ### ### ### ### ###

### ### ### ### ### ### ###

### ### ### ### ### ### ###


### ### ### ### ### ### ###

the time tau as parameter

0.02
tau = 10 (s) 0.04
tau = 20 (s) 0.06 0.08 0.1
tau = 60 (s) x

rev.cjc.21.04.2018

page 3 of 3

Time step to obtain Fo =1/6


( L )2
τ st =τ step|Fo=1/6=
6⋅α
α⋅τ st
Fo = 2
( L)
Microsoft Equation
3.0
Microsoft Equation
3.0

T0: slab initial temperature


Initial condition T(x, t=0) = To
Ts: surface temperature ( t > 0+)
(at x = ± L)
Slab midplane at x = 0
Dimensionless temperature
Tadim (T - Ts) / (T0 - Ts)
T - Ts =Tadim * (T0 -Ts)
T = Ts + Tadim * (T0 -Ts)
L
x
-0.1 x=0 x 0.1
Temperature response of a slab [2]

Analytic solution
A slab is initially at uniform temperature T ini . Fo
At time t = 0, it is inmersed in a fluid at temperature T s.
0.01
Considering the case of an infinite value of the 0.03
convection coefficient, the dimensionless temperature 0.1
is given by equation (3.44), [2], page 151. 0.3
1
Application of VB function
Tadim = Tadim_Alpha_L_tau_x Dimen
Alpha = 1.10E-05 m²/s
L= 0.1 m 1.00
tau = 90.9 s
0.90
x= 0.06 m
Tadim = #VALUE! - 0.80

Tadim (-)
0.70
Dx = 0.1
0.60

0.50
Fo = Alpha * t / L^2
t = Fo * L^2 / a 0.40
Fo = 0.01
0.30
L= 0.1
a= 1.10E-05 0.20
t = 9.09
0.10

0.00
-0.1

For
Tini = 100 ºC Fo
Ts = 0 ºC
0.01
Tadim = (T - Ts) / (Tini - Ts) 0.03
T - Ts = Tadim * (Tini -Ts) 0.1
T= Ts + Tadim * (Tini -Ts) 0.3
1
Evaluation at point whith location
x= 0.06 m
at a time
100
t= 40 s

Temperature (ºC)
90
Fo
1
Tadim = Tadim_Alpha_L_tau_x 80
Alpha = 1.10E-05
70
L= 1.0E-01 Fo
tau = 91 60
3
x= 0.06
Tadim = #VALUE! 50
Fo
40
T= #VALUE! ºC
30
Fo
20

10 Fo

0
-0.1 -0.08

Temperature response of a slab

A slab is initially at uniform temperature T 0 .


At time t = 0, it is inmersed in a fluid at temperature T s.

Considering the case of an infinite value of the


convection coefficient, the dimensionless temperature
is given by equation (3.44), [1], page 151.
Required is the tempeature response of the slab.
Temperature response of a slab
Dimensionless temperature, according equation (3 . 44 ), [1 ] page
n
T-T s ∞
2⋅( -1 ) −( n+1/2 )2⋅π 2⋅Fo
=∑ ⋅e ⋅cos ( ( n+1/2 ) ⋅π⋅( x /L )) (3
T 0 -T s n = 0 ( n+1/2 )⋅π
where Fo is the Fourier number
α⋅τ
Fo= 2
L
α :thermal diffusivity ( m2 /s )
τ :time ( s)
L:half thickness of slab ( m)
T s : surface temperature for τ (0+) ( K )
T 0 : initial slab temperature (K )

=
n
T-T s ∞
2⋅( -1 ) −(n+1/2)2⋅π 2⋅Fo
Dimensionless temperature of a slab according equation (3.44) [2] =∑ ⋅e ⋅cos ( ( n+1
T 0 -T s n = 0 ( n+1/2 )⋅π
Dimensionless temperature Tadim (-)
tau Distance x [m]
s -0.1 -0.09 -0.08 -0.07 -0.06 -0.05 -0.04 -0.03 -0.02 -0.01 0 0.01 0.02 0.03
9.09 ### ### ### ### ### ### ### ### ### ### ### ### ### ###
27.27 ### ### ### ### ### ### ### ### ### ### ### ### ### ###
90.91 ### ### ### ### ### ### ### ### ### ### ### ### ### ###
272.73 ### ### ### ### ### ### ### ### ### ### ### ### ### ###
909.09 ### ### ### ### ### ### ### ### ### ### ### ### ### ###

IF(Tadim_Alpha_L_tau_x($E$15,$E$16,$K8,L$7)>0,Tadim_Alpha_L_tau_x($E$15,$E$16,$K8,L$7),0)
Dimensionless temperature as function of distance x, with Fourier number as parameter (
0.1
1.1E-05 9 -0.1
1.00 Alpha L tau x
0.90

0.80 Fo=0.01
Tadim (-)

0.70
Fo=0.03
0.60

0.50
Fo=0.1

0.40

Fo=0.3
0.30

0.20
Fo=1
0.10

0.00
-0.1 -0.08 -0.06 -0.04 -0.02 0 0.02 0.04 0.0
Distance from midplane x (m)

Temperature
tau Distance x [m]
s -0.1 -0.09 -0.08 -0.07 -0.06 -0.05 -0.04 -0.03 -0.02 -0.01 0 0.01 0.02 0.03
9 ### ### ### ### ### ### ### ### ### ### ### ### ### ###

27 ### ### ### ### ### ### ### ### ### ### ### ### ### ###

91 ### ### ### ### ### ### ### ### ### ### ### ### ### ###

273 ### ### ### ### ### ### ### ### ### ### ### ### ### ###
909 ### ### ### ### ### ### ### ### ### ### ### ### ### ###

Temperature vs. distance, with Fourier number as parameter


100
Temperature (ºC)

90
Fo=0.0
1
80 Location Time
x t x tau
70
m
Fo=0.0
ºC m s
3 0.06 0.0 -0.10 40.0
60
0.06 10.0 -0.08 40.0
50 0.06 20.0 -0.06 40.0
Fo=0.1
0.06 30.0 -0.04 40.0
40
0.06 40.0 -0.02 40.0
30 0.06 50.0 0.00 40.0
Fo=0.3
0.06 60.0 0.02 40.0
20 0.06 70.0 0.04 40.0
0.06 80.0 0.06 40.0
10 Fo=1
0.08 40.0
0 0.10 40.0
-0.1 -0.08 -0.06 -0.04 -0.02 0 0.02 0.04 0.06
distance from midplane x (m)

Fourier number
Fo = a * tau/L²
tau = Fo * L²/a (s)
(3 . 44 ), [1 ] page 151 Tadim = (T - Ts) / (Tini - Ts)

Eq. (3.44) [1], page 151


/2 ) ⋅π⋅( x /L )) (3. 44 ) Tadim = Sum (A * B * C) from n = 0 to infinity
A = 2 * (-1) ^ n / ((n + 1 / 2) * pi)
B = Exp(-(n + 1 / 2) ^ 2 * pi ^ 2 * Fo)
C = Cos((n + 1 / 2) * pi * (x / L))

T - Ts =

Microsoft Equation
3.0
n page 1 of 3
2⋅( -1 ) −(n+1/2)2⋅π 2⋅Fo
⋅e ⋅cos ( ( n+1/2 ) ⋅π⋅( x/L )) (3. 44)
+1/2 )⋅π
(-)

0.04 0.05 0.06 0.07 0.08 0.09 0.1


### ### ### ### ### ### ###
### ### ### ### ### ### ###
### ### ### ### ### ### ###
### ### ### ### ### ### ###
### ### ### ### ### ### ###

,$E$16,$K8,L$7),0)
mber as parameter (-)

0.04 0.06 0.08 0.1

page 2 of 3

0.04 0.05 0.06 0.07 0.08 0.09 0.1


### ### ### ### ### ### ###

### ### ### ### ### ### ###

### ### ### ### ### ### ###

### ### ### ### ### ### ###


### ### ### ### ### ### ###

rameter

0.04 0.06 0.08 0.1

rev.cjc.21.04.2018

page 3 of 3

Time step to obtain Fo =1/6


( L )2
τ st =τ step|Fo=1/6=
6⋅α
α⋅τ st
Fo = 2
( L)
Microsoft Equation
3.0
T0: slab initial temperature
Initial condition T(x, t=0) = To
Ts: surface temperature ( t > 0+)
(at x = ± L)
Slab midplane at x = 0
Dimensionless temperature
Tadim (T - Ts) / (T0 - Ts)
T - Ts =Tadim * (T0 -Ts)
T = Ts + Tadim * (T0 -Ts)
L
x
-0.1 x=0 x 0.1
Start

Dimensioning
Constants

'read in input data from spreadsheet

tinitial = Cells(5, 3).Value 'initial time, typically 0


x1 = Cells(6, 3).Value 'initial x
x2 = Cells(7, 3).Value 'final x
Alpha = Cells(8, 3).Value 'thermal diffusivity
tfinal = Cells(9, 3).Value 'final time
nDelta_x = Cells(10, 3).Value 'number of distance intervals

Help variables

'Slab width
Wslab = x2 - x1 ' (m) Slab Width.
'Distance interval
Delta_x = (Wslab) / nDelta_x ' (m) distance interval, Lslab/nDelta_x
'Step time
tstep = Delta_x ^ 2 / (6 * Alpha) ' (s) time step (to obtain Fo = 1/6)
'Fourier number
Fo = Alpha * tstep / Delta_x ^ 2 ' (-) Fourier number must be <0.5
'Number of time intervals
nDelta_t = (tfinal - tinitial) / tstep ' (-) number of time intervals

Value of times row (for the time columns)


Eq, (1)
using a For next

Initial temperature condition


Values of the column for time t = 0
V(i) value for the rows x1 to x2

Starting values
t = tinitial 'set to the initial value
iter = 0 'the number of iterations
j=3 'actual column number
calculation and output
Main loop
Finite difference equation applied to column j

Values of column "j"


U(i) = V(i) + Fo * (V(i + 1) - 2 * V(i) + V(i - 1))
Calculated column is stored
V(i) = U(i) 'over writes array V for next time interval
Control
iter = iter + 1 'increment interation counter
Boundary condition at this time
U(0) = P(t) 'boundary condition 1
U(nDelta_x) = Q(t) 'boundary condition 2
Conditions to go to next column
If Abs(t - t_out(1)) < tstep / 2 Or _
Abs(t - t_out(2)) < tstep / 2 Or _
Abs(t - t_out(3)) < tstep / 2 Or _
Abs(t - t_out(4)) < tstep / 2 Or _
Abs(t - t_out(5)) < tstep / 2 Then ' output other interval
CR = 21 ' reset current row
For i = 0 To nDelta_x ' output to each row in column j
Cells(CR + i, j) = U(i)
Next i
j=j+1 'increment column
End If
t = t + tstep ' increment time to next interval
'keep calculating until time is within 1/2 interval of tmax
Loop While Abs(tfinal - t) > tstep / 2

N If Abs(tfinal-t) > tstep 2

Y
end_of_main_loop:

'output results - final time interval at each location


CR = 21 'current row for output start
For i = 0 To nDelta_x & Cells(CR + i, 2) = x
x = x1 + i * Delta_x & Cells(CR + i, 8) = U(i)
Next i
Cells(43, 1) = "iterations:"
Cells(43, 2) = iter

End
tau for Fo = 1/6

Fourier number
Fo = a * tau/L²
tau = Fo * L² / Alpha
Fo = 1/6
tau = L² /(6 * Alpha)
[1] ChemEcalcs
Jeff Munic
http://www.chemecalcs.com/heat-equation.php

[2] Heat and mass transfer


Anthony F. Mills
Irwin, 1995
[1]

Screen shot of Jeff Munic example


http://www.chemecalcs.com/heat-equation.php
Public pi As Double
Sub gohere() 'The three functions for initial and boundary conditions are listed below:
End Sub

Function F(x)
'initial condition, insert function F(x) here:
'A function list can be found at Help |VB Documentation|VB Lang Reference|Functions
F = 100 * Sin(pi * x)
End Function

Function P(t)
' boundary condition at x=x1, insert function P(t) here:
P=0
End Function

Function Q(t)
'boundary condition at x=x2, insert function Q(t) here:
Q=0
End Function

Sub heat_eq()

Dim U(200) As Double, V(200) As Double


Dim r As Double, t_out(5) As Variant
pi = Cells(14, 2).Value

'read in input data from spreadsheet


t_init = Cells(5, 2).Value 'initial time, typically 0
x1 = Cells(6, 2).Value 'initial x
x2 = Cells(7, 2).Value 'final x
Kappa = Cells(8, 2).Value 'diffusivity
t_max = Cells(9, 2).Value 'final time
n = Cells(10, 2).Value 'number of distance intervals
h = Cells(11, 2).Value 'length of the x intervals
k = Cells(12, 2).Value 'time step
r = Kappa * k / h / h 'lump parameter for stability determination
m = (t_max - t_init) / k 'number of time intervals
For i = 1 To 5
t_out(i) = Cells(20, 2 + i).Value 'the time interval to output results
Next i
'error condition
If r > 0.5 Then MsgBox "ERROR, r>0.5, not stable"

'initial condition

For i = 0 To n
x = x1 + i * h
V(i) = F(x)
Next i
t = t_init
iter = 0 'the number of iterations
j=3 'column number for initial output

'main loop
Do
For i = 1 To n - 1
'below is the main finite difference equation
U(i) = V(i) + r * (V(i + 1) - 2 * V(i) + V(i - 1))
Next i

iter = iter + 1 'increment interation counter


U(0) = P(t) 'boundary condition 1
U(n) = Q(t) 'boundary condition 2

For i = 0 To n
V(i) = U(i) 'over writes array V for next time interval
Next i
'error checking: prevent infinite loop
If iter > 50000 Then
MsgBox ("Error, the program is not solved after 50,000 iterations")
GoTo end_of_main_loop
End If

If Abs(t - t_out(1)) < k / 2 Or Abs(t - t_out(2)) < k / 2 Or Abs(t - t_out(3)) < k / 2 Or Abs(t - t_out(4)) < k / 2 Or Abs(t
CR = 21 'reset current row
For i = 0 To n 'output to each row in column j
Cells(CR + i, j) = U(i)
Next i
j=j+1 'increment column
End If
t=t+k ' increment time to next interval
'keep calculating until time is within 1/2 interval of tmax
Loop While Abs(t_max - t) > k / 2
end_of_main_loop:

'output results - final time interval at each location


CR = 21 'current row for output start
For i = 0 To n
x = x1 + i * h
Cells(CR + i, 2) = x
Cells(CR + i, 8) = U(i)
Next i
Cells(CR + n + 2, 1) = "iterations:"
Cells(CR + n + 2, 2) = iter

End Sub
- t_out(4)) < k / 2 Or Abs(t - t_out(5)) < k / 2 Then 'output other interval
Temperature response of a slab with negligible surface resistance
Deduction of the analytic solution [2]

A slab is initially at uniform temperature T0 .


At time t = 0, it is inmersed in a fluid at temperature T s.
Considering the case of an infinite value of the
convection coefficient, the dimensionless temperature
is given by equation (3.44), [2], page 151.

Temperature response of a slab


Dimensionless temperature, according equation (3 . 44 ), [2 ] page 1
n
T-T s ∞
2⋅( -1 ) )2 2
⋅e− n+1/2 ⋅π ⋅Fo⋅cos ( ( n+1/2 ) ⋅π⋅( x /L )) (3. 4
(
=∑
T 0 -T s n = 0 ( n+1/2 )⋅π
where Fo is the Fourier number
α⋅τ
Fo= 2
L
α :thermal diffusivity ( m2 /s )
τ :time ( s)
L:half thickness of slab ( m)
Temperature . Any unit can be used .
In this application, let
T s : surface temperature for τ (0+) (ºC)
T 0 : initial slab temperature (ºC)
2L

44 ), [2 ] page 151

⋅π⋅( x /L )) (3. 44 )

-L 0 L x

Slab of thickness 2L, initially at temperature T0

n
T-T s ∞
2⋅( -1 ) −( n+1/2 )2⋅π2⋅Fo
=∑ ⋅e ⋅cos ( ( n
T 0 -T s n = 0 ( n+1/2 )⋅π
Microsoft Equation
3.0
n
T-T s ∞
2⋅( -1 ) −( n+1/2 )2⋅π 2⋅Fo
=∑ ⋅e ⋅cos ( ( n+1/2 ) ⋅π⋅( x /L ))
T 0 -T s n = 0 ( n+1/2 )⋅π
rev.cjc.03.05.2018

page 1 of 3

1/2 )2⋅π 2⋅Fo


⋅cos ( ( n+1/2 ) ⋅π⋅( x/L )) (3. 44)

page 2 of 3
page 3 of 3
⋅π⋅( x /L )) (3. 44 )

You might also like