tesi a.dmytriv

25
UNIVERSITÀ DEGLI STUDI DI NAPOLI FEDERICO II Facoltà di Ingegneria Corso di Laurea in Ingegneria Aerospaziale Tesi di Laurea Triennale Numerical Schemes Based on Spline Interpolation and Their Application to Eigenvalues Problem Relatore: prof. Gennaro Coppola Laureando: Adrian Dmytriv matr. N35/38 Anno accademico 2010-2011

Upload: pipino-il-breve

Post on 28-Apr-2015

31 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Tesi a.dmytriv

UNIVERSITÀ DEGLI STUDI DI NAPOLI FEDERICO II

Facoltà di IngegneriaCorso di Laurea in Ingegneria Aerospaziale

Tesi di Laurea Triennale

Numerical Schemes Based on SplineInterpolation and Their Application

to Eigenvalues Problem

Relatore:prof. Gennaro Coppola

Laureando:Adrian Dmytrivmatr. N35/38

Anno accademico 2010-2011

Page 2: Tesi a.dmytriv

Contents

1 Cubic splines 11.1 Formulations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Derivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3 Alternative formulation . . . . . . . . . . . . . . . . . . . . . . . . . . 31.4 Endpoints conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.4.1 Natural spline . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.4.2 Clamped spline . . . . . . . . . . . . . . . . . . . . . . . . . . 41.4.3 Not-a-knot . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 Spline schemes 62.1 Spline in Matlab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.2 Derivative operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.3 Example of application . . . . . . . . . . . . . . . . . . . . . . . . . . 8

3 Graetz problem 103.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103.2 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103.3 Numerical solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153.4 Scripts used . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

3.4.1 Calculation of the autofunctions . . . . . . . . . . . . . . . . . 193.4.2 Calculation of the temperature . . . . . . . . . . . . . . . . . 20

Bibliography 23

ii

Page 3: Tesi a.dmytriv

Chapter 1

Cubic splines

1.1 Formulations

Definition: Given n data points (x1, y1), ..., (xn, yn) a cubic spline is a piecewise-defined function of the form:

S1(x) = y1 +b1(x−x1)+c1(x−x1)2 +d1(x−x1)3 for x ∈ (x1, x2)

S2(x) = y2 +b2(x−x2)+c2(x−x2)2 +d2(x−x2)3 for x ∈ (x2, x3)

................ ....................

Sn−1(x) = yn−1+bn−1(x−xn−1)+c2(x−xn−1)2+dn−1(x−xn−1)3 for x ∈ (xn−1, xn)

The 3n − 3 unknowns (bi, ci, di) are chosen to satisfy the interpolation constraintsand also some smoothness constraints:

• Interpolation Conditions: we already have Si(xi) = yi for i = 1 to n − 1. Inaddition, we want the overall function to be continuous. At the interior points,i = 1, 2, ..., n− 2,

Si(xi+1) = Si+1(xi+1) = yi+1

and at the far right value of x, Sn−1(xn) = yn. Altogether, there are n − 1constraints here.

• Smoothness Condition 1: at the interior points,

S ′i(xi+1) = S ′i+1(xi+1).

There are n− 2 constraints here.

1

Page 4: Tesi a.dmytriv

1 – Cubic splines

• Smoothness Condition 2 : at the interior points,

S ′′i (xi+1) = S ′′i+1(xi+1).

There are n− 2 constraints here.

So far, we have (n − 1) + (n − 2) + (n − 2) = 3n − 5 constraints, but we have3(n − 1) = 3n − 3 coefficients. We need two more constraints to define the cubicsuniquely. We can have different cubic splines depending on how we want to use ourtwo extra constraints. Here are some common ones:

• The Natural Spline: S ′′1 (x1) = 0 = S ′′n−1(xn)

• The Clamped Spline: the user defines S ′1(x1) and S ′n−1(xn)

• ’Not-A-Knot’ : ( Matlab Default ) Third derivatives match at x2 and xn−1:

S ′′′1 (x2) = S ′′′2 (x2)

S ′′′n−2(xn−2) = S ′′′n−1(xn−2)

1.2 Derivation

Now we need to find the espressions for the derivatives of Si :

Si(x) = ai + bi(x− xi) + ci(x− xi)2 + di(x− xi)3

S ′i(x) = bi + 2ci(x− xi) + 3di(x− xi)2

S ′′i (x) = 2ci + 6di(x− xi)

It is very helpful to introduce the hi = (xi+1 − xi). Then the spline conditions onthe uniform mesh can be written as follows:

• Si(xi) = yi for y = 0, 1, ..., n− 1 : ai = yi

• Si(xi+1) = yi+1 for y = 0, 1, ..., n− 1 : ai + hibi + h2i ci + h3

i di =yi+1

• S ′i(xi+1) = S ′i+1(xi+1) for y = 0, 1, ..., n−2 : bi+2hici+3h2i di−bi+1 = 0

• S ′′i (xi+1) = S ′′i+1(xi+1) for y = 0, 1, ..., n− 2 : 2ci + 6hidi − 2ci+1

Obtained equations above can be written as a linear system for the 4n unknowns.

2

Page 5: Tesi a.dmytriv

1 – Cubic splines

1.3 Alternative formulation

This linear system can be simplified considerably by defining mi = S ′′i (xi) = 2cior ci = mi

2and thinking of the mi as unknowns instead. Then:

• S ′′i (xi+1) = S ′′i+1(xi+1) 1 for i = 0, 1, ..., n− 2 :−→ 2ci + 6hidi − 2ci+1 = 0−→ mi + 6hidi −mi+1 = 0−→ di = mi+1−m−i

6hi

• Si(xi) = yi and Si(xi+1) = yi+1 for i = 0, 1, ..., n− 1 :−→ yi + hibi + h2

i ci + h3i di = yi+1

Substitute ci, di and di from above:−→ bi = yi+1−yi

hi− himi

2− hi(mi+1−mi)

6

• S ′i(xi+1) = S ′i+1(xi+1) for i = 0, 1, 2, ..., n− 2 :−→ bi + 2hici + 3h2

i di = bi+1

Substitute bi, ci and di from above and simplify:−→ himi + 2(hi + hi+1)mi+1 + hi+1mi+2 = 6(yi+2−yi+1

hi+1− yi+1−yi

hi)

Notice: these are n− 1 linear equations for n+ 1 unknowns (mi)

1.4 Endpoints conditions

1.4.1 Natural spline

In this case we have m0 = 0 and mn = 0 for taken together gives an (n+1)×(n+1)system:

1 0 0 ... 0h0 2(h0 + h1) h1 00 h1 2(h1 + h2) h2 00 0 h2 2(h2 + h3) h3

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .0 hn−2 2(hn−2 + hn−1) hn−1

0 0 1

m0

m1

m2

m3......mn

=

3

Page 6: Tesi a.dmytriv

1 – Cubic splines

6

0y2−y1h1− y1−y0

h0y3−y2h2− y2−y1

h1y4−y3h3− y3−y2

h2...yn−yn−1

hn−1− yn−1−yn−2

hn−2

0

as we see we could just drop the equations for m0 and mn and write it as an(n− 1)(n− 1) system.

1.4.2 Clamped spline

Clamped Spline, sometimes called a “complete spline” (derivative is specified):S ′0(x0) = A −→ b0 = A

−→ A = y1−y0h0− h0m0

2− h0(m1−m0)

6

−→ 2h0m0 + h0m1 = 6(y1−y0h0− A)

and S ′n−1(xn) = B −→ bn−1 = B−→ hn−1mn−1 + 2hn−1mn = 6(B − yn−yn−1

hn−1)

So, we put this two equations in the first and the last rows:

2h0 h0 0 ... 0h0 2(h0 + h1) h1 00 h1 2(h1 + h2) h2 00 0 h2 2(h2 + h3) h3

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .0 hn−2 2(hn−2 + hn−1) hn−1

0 hn−1 2hn−1

1.4.3 Not-a-knot

In this case the third derivate is matching:

S ′′′0 (x1) = S ′′′1 (x1) and S ′′′n−2(xn−1) = S ′′′n−11(xn−1)

Using S ′′′i (x) = 6di and di = mi+1−mi

6, these conditions become m1−m0 = m2−m1

and mn−1 −mn−2 = mn −mn−1 . The matrix in this case is:

4

Page 7: Tesi a.dmytriv

1 – Cubic splines

−1 2 −1 ... 0h0 2(h0 + h1) h1 00 h1 2(h1 + h2) h2 00 0 h2 2(h2 + h3) h3

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .0 hn−2 2(hn−2 + hn−1) hn−1

−1 2 −1

5

Page 8: Tesi a.dmytriv

Chapter 2

Spline schemes

2.1 Spline in Matlab

For the implementation of spline interpolation in Matlab the relevant commandsare spline, ppval and mkpp. Suppose, that we need to interpolate n (in this case10) values (xi, yi) , so by writing F=spline (x, y), where (x, y) are vectors containinginterpolating values is obtained sctructure:

form: ’pp’breaks: [1 2 3 4 5 6 7 8 9 10]coefs: [9x4]order: 4

dim: 1 ,

where: ’pp’ is abbreviation of piecewise polynomial form; breaks containing nodalvalues of xi(in our case from 1 to 10); coefs containing 4 coefficients for every ofthe local polynomial, starting from the higher order (4) ; order is 4 becauseMatlabinterprets it like the number of the coefficiets that we need to define uniquely thecubic spline; dim is 1 becouse we use vectors and not arrays for the representation ofx, y. Once, the struct was obtained, we can get the values of interpolated functionfor any x included in the range of break points and even outside by commandppval(F,x). If we have operated with the coefficients and we need to put themback to ’pp’ form, is sufficiente to write mkpp(coefs,x), where size correlationmust be matched. As we said before, Matlab use ’not-a-knot’ endpoints conditionfor cubic spline.

6

Page 9: Tesi a.dmytriv

2 – Spline schemes

2.2 Derivative operator

As we know, the derivative is a linear operator. On the discrete domain it canbe approsimated by a matrix. Considering one dimensional space where we known values of the generic function , our aim becomes to find the matrix D containingthe weights of the derivatives :

d

dx

f1

f2

...fn

= [D]

f1

f2

...fn

The construction of the matrix D is based on the fact that analitical derivationof interpolating polynomial permit to obtain values of numerical derivative of thefunction. In particular, if we cosider n− th order polinomial

a0 + a1(x− x0) + a2(x− x0)2 + ...+ an(x− x0)n, (2.1)

the discrete derivative of k − th order f (k) evaluatd in x0 is given by relation

f (k) = k!ak. (2.2)

Then to obtain f (k) we derive k times interpolating polynomial

k!ak + (k + 1)!ak+1(x− x0) + ...+n!

k!an(x− x0)n−k (2.3)

and evaluate it at x0 , in this way remains only k!ak and the other terms disappear.The next step is to apply this operation to the identity matrix nxn. This proceduregives ′weights′, that we are going to multipy by the appropriate values of the functionand it will return the values of numerical derivative at the placement point. So wehave created the ruotines using this approach, were the local cubic spline was usedas interpolating polinomial. Hence, we have

fi(x) = ai(x− xi)3 + bi(x− xi)2 + ci(x− xi) + di (2.4)

f ′i(x) = 3ai(x− xi)2 + 2bi(x− xi) + ci (2.5)

f ′′i (x) = 6ai(x− xi) + 2bi(x− xi). (2.6)

That moltiplications were done on the rows 5 and 6 of the reported script:

7

Page 10: Tesi a.dmytriv

2 – Spline schemes

function d=drvtspl(x,y)

pp = spline(x,y) ; % costruzione della spline nella pp-formC = pp.coefs ; % estraggo i coefficientiCder1 = [3*C(:,1) 2*C(:,2) C(:,3)] ; % derivata primaCder2 = [6*C(:,1) 2*C(:,2)] ; % derivata secondappder1 = mkpp(x,Cder1) ; % genera una nuova variabile ppppder2 = mkpp(x,Cder2) ; % genera una nuova variabile ppspd1 = ppval(ppder1,x) ; % valutazione della derivata primaspd2 = ppval(ppder2,x) ; % valutazione della derivata secondad = [spd1;spd2] ; % inserisco valori delle derivate ,

Using that routine we are going to evaluate the numerical derivatives (first andsecond) of each column-vector of the identity matrix :

function D=MD_spline(x,oderv)

N = length(x) ; % lunghezza vettore xI = eye(N) ; % matrice canonicaD = zeros(N,N,2) ; % matrice delle derivate 1 e 2for i=1:N

Dloc = drvtspl(x,I(:,i)) ; % derivazione vettori componentiD(:,i,1) = Dloc(1,:)’ ; % inserimento valore derivata 1D(:,i,2) = Dloc(2,:)’ ; % inserimento valore derivata 2

endif nargin ==2 % se input contiene 2 valori allora

D = D(:,:,oderv) ; % memorizzo solo derivata specificataend ; % da ’oderv’

2.3 Example of applicationAs an example we can analyze the matrix of weights of the second derivative on

discrete domain [0; 1] composed of 30 knots with Dirichlet boundary conditions. Onthe following figure (2.1) we can see the relative error in the evaluation of the first10 eigenvalues and its comparison with the results obtained using finite differencescheme of the second order. As we can see our scheme with the splines has thesame accuracy of FDS. The next figure (2.2) shows the error of the same evaluationduring increasing of the points number of x.

8

Page 11: Tesi a.dmytriv

2 – Spline schemes

1 2 3 4 5 6 7 8 9 1010

−4

10−3

10−2

10−1

Errore relativo nella valutazione di 10−imo autovalore

Spline

FDS

Figure 2.1: Comparison of the relative error in the evaluation of the first 10 eigen-values using the second order difference schemes and the cubic spline.

101

102

103

10−4

10−3

10−2

10−1

100

Errore relativo di 10−imo autovalore al variare di N

Err

or

N = num. di punti

Spline

FDS

Figure 2.2: Comparison of the relative error in the evaluation of the 10-th eigenvalueusing the second order difference schemes and the cubic spline and changing theknots number.

9

Page 12: Tesi a.dmytriv

Chapter 3

Graetz problem

3.1 Introduction

By the end of the last century, the problem of forced convection heat transfer in acircular tube in laminar flow gained interest because of its fundamental importancein physical problems such as the analysis and design of heat exchangers. The Graetzproblem is a simplified case of the problem of forced convection heat transfer in acircular tube with laminar flow. With the assumptions of steady, incompressible andfully established flow, constant fluid properties, no "swirl" component of velocity, afully developed temperature profile, and negligible energy dissipation effects, Graetz(1883) originally solved this problem analytically. The solution by Graetz involvedan infinite number of eigenvalues, and in his paper only the first two eigenvalueswere evaluated. Since the accuracy of the Graetz solution mainly depends on thenumber of eigenvalues, it is extremely important to obtain more eigenvalues. Sellars(1956) extended the problem to include a more effective approximation techniquefor evaluation of the eigenvalues of the problem; they could get any number of eigen-values as needed. This work solved the Graetz problem completely.

3.2 Description

As we have seen the Graetz problem is the problem of development of the profilesof temperature T (x, r) in a duct with sudden temperature change on the wall. Sothe problem that we are going to resolve concerns duct subjects to a set temperatureof the wall, of which we analyze the area dynamically developed in which we haveparabolic profile of velocity, but not developed thermally. In this case the fieldtemperature is a function of the coordinates x and r, where x is the axis of symmetry,and r is the radius (Figure 3.1 on the following page).

10

Page 13: Tesi a.dmytriv

3 – Graetz problem

Figure 3.1

Neglecting dissipation and heat conduction along the axis, the energy equation

ρCpDT

Dt= κ∇2T + µΦ (3.1)

in cylindrical coordinates becomes

u∂T

∂x=α

r

∂r(r∂T

∂r), (3.2)

where α = κρCp

is the thermal diffusivity of the fluid. The velocity distributionu(x, r) is assumed known in the equation and could be one of the following threetypes :

• u = u = const or slug flux: suitable for low Prandtl numbers, so for fluidssuch as liquid metals, where the temperature T is evolving much faster thanthe velocity u;

• u = 2u(1− r2

r20) or Poiseuille velocity: appropriate for high Prandtl numbers, so

for fluids such as oils, where the thermal input is far away and so is downstreamthe entry of the duct;

• developing profiles of u: it can be used for each Prandtl number, but thismethod is normally used when the velocity and temperature at the duct entryare in the same position.

We are going to use the Graetz solution for second case ( Poiseuille ). Withreference to figure (3.1) we impose the appropriate boundary conditions on T (x, r)for the equation ( 3.2) :

T (0, r) = T0 for x ≤ 0 (3.3)

T (r0, x) = Tw for x > 0. (3.4)

11

Page 14: Tesi a.dmytriv

3 – Graetz problem

Since T ranges from T0 (inlet temperature) to Tw (wall temperature) and r variesbetween 0 and r0 (radius of the duct) becomes convenient to use dimensionlessvariables, in this way we can eliminate the thermal diffusivity coefficient α. Hence,

T ∗ =Tw − TTw − To

(3.5)

r∗ =r

r0

(3.6)

x∗ =x

d0RePr, (3.7)

where Re = ud0ν

is the Reynolds number referred to the diameter d0 and Pr isthe Prandtl number which together form the Peclet number Pe = PrRe = ρCpd0

κ.

Combining the equation (3.2) with the dimensionless variable we obtain

∂T ∗

∂x∗=

2

r∗(1− r∗2)

∂r∗(r∗

∂T ∗

∂r∗), (3.8)

where T ∗(r∗,0) = 1 and T ∗(1, x∗) = 0. Note that this equation is totally independentof the parameters, due to our choice of variables (T ∗, r∗, x∗). It’s clear that thevariables are separable, so that we can get a solution in this form:

T ∗(r∗, x∗) = f(r∗)g(x∗). (3.9)

That is a particular solution and replacing it in equation (3.8) we obtain:

g′

2g=

r∗f ′′ + f ′

r∗(1− r∗2)f= −λ2 = cost. (3.10)

The function g has the solution g = Ce−2λ2x∗ while finding the solution of f is morecomplicated. To obtain the solution T = fg satisfying condition T ∗(r∗,0) = 1 forall r∗ we exploit the linearity of the equation and overlay many similar solutions, sofinally the suitable formulation becomes:

T ∗(r∗, x∗) =∞∑n=0

Cnfn(r∗)e−2λ2x∗ . (3.11)

Where the functions fn has the characteristics of solutions of the equation (3.10):

r∗f ′′n + f ′n + λ2nr∗(1− r∗2)fn = 0, (3.12)

where we take for simplicity fn(0) = 1, fn(1) = 0 for satisfy the condition of walltemperature T ∗(1, x∗) = 0 from equation (3.8). Then the solution will be completeif it rispect the other initial conditions of the same equation :

T ∗(r∗,0) = 1 =∞∑n=0

Cnfn(r∗). (3.13)

12

Page 15: Tesi a.dmytriv

3 – Graetz problem

Graetz showed, that in the finite interval between 0 and 1 the eigenfunctions fn areorthogonal to the load function r∗(1− r∗2). So if we multiply the equation (3.13) byr∗(1− r∗2) and integrate between 0 and 1, we can calculate the constants as follows:

Cn =

∫ 1

0r∗(1− r∗2)fndr

∗∫ 1

0r∗(1− r∗2)f 2

ndr∗

(3.14)

Table 3.1: Important costants for Graetz problem

n λn Cn −Cnf ′n(1)0 2.7043644 1.46622 1.497581 6.679032 -0.802476 1.088482 10.67338 0.587094 0.925763 14.67108 -0.474897 0.830364 18.66987 0.404402 0.764745 22.67 -0.35535 0.715716 26.67 0.31886 0.677987 30.67 -0.29049 0.647118 34.67 0.26769 0.621199 38.67 -0.24890 0.59900

The first ten values are tabulated in table ( 3.1). So the equation (3.12) withits two conditions is an eigenvalue problem of the functions fn. The table (3.1)shows the first 10 eigenvalues and the constants associated with them. These aresufficient to calculate the Nusselt numbers for every condition on the wall, even foran arbitrary distribution of Tw. For large n Sellar gave the following approximations:

λn = 4(n− 1) +8

3(3.15)

Cn = (−1)n2Γ(2

3)6

23

πλ23n

(3.16)

− Cnf ′n(1) =4(4

3)16 Γ(2

3)

πλ13nΓ(4

3)

. (3.17)

These formulas are used to calculate the last five digits of the table with an errorless than 0,15 percent.

13

Page 16: Tesi a.dmytriv

3 – Graetz problem

The heat flux from the wall to the fluid, qw(x) is a function of axial position. Itcan be calculated directly by using Fourier law :

qw(x) = κ∂T

∂r(r, x). (3.18)

It is customary to define a heat transfer coefficient h(x) as :

qw(x) = h(x)(Tw − Tb), (3.19)

where the bulk or cup-mixing average temperature Tb is introduced. The way todetermine experimentally the bulk average temperature is to collect the fluid comingout of the system at a given axial location, mix it completely, and measure itstemperature. The mathematical definition of the bulk average temperature is:

Tb =

∫Tdm∫dm

=

∫ r00

2πruTdr∫ r00

2πrudr, (3.20)

where constant density was simplify and u = 2u(1− r2

r20) (Poiseuille). We can see from

the definition of the heat transfer coefficient that it is related to the temperaturegradient at the tube wall in a simple manner :

h =κ∂T∂r

Tw − Tb. (3.21)

So, we can define a dimensionless heat transfer coefficient, which is known as theNusselt number:

Nu(x) =2hr0

κ= −2

∂T ∗

∂x∗

T ∗b, (3.22)

where Tb is the dimensionless bulk average temperature. By substituting from theinfinite series solution for both the numerator and the denominator, the Nusseltnumber can be written as follows

Nu(x∗) =

∑Cnf

′n(1)−2λ2nx

2∑Cnλ−2

n f ′n(1)−2λ2nx∗ . (3.23)

We can see that for large x∗(> 0.05), only the first term in the infinite series inthe numerator, and also the first term in the infinite series in the denominator, isimportant. Therefore,

Nu −→ λ21

2= 3.656. (3.24)

14

Page 17: Tesi a.dmytriv

3 – Graetz problem

3.3 Numerical solutionAs we have seen the Graetz problem is an eigenvalue problem. In the literature

there are many problems in physics-mathematics with formulation of this type. Adifferential eigenvalues problem, on bounded domain usually admits an infinite num-ber of eigenvalues that form the so-called discrete spectrum. The dicretization of

0 0.2 0.4 0.6 0.8 1−0.5

0

0.5

1autofunctions

f(r*

)

r*=r/ro

Figure 3.2

the eigenvalue problem leads to an algebrical problem with a finite number of eigen-values. On the discrete domain, to every linear operator can be associated a matrix,therefore, since the derivative operator is a linear operator, it is associated with amatrix that represents the operation of derivation. Our problem is to determine λwhich are the characteristics solutions of the function fn. So the equation

r∗f ′′n + f ′n + λ2nr∗(1− r∗2)fn = 0 (3.25)

becomes[r∗D2 +D1]]f = −λ2r∗(1− r∗2) (3.26)

now we callA = −[r∗D2 +D1]] (3.27)

B = r∗(1− r∗2) (3.28)

and in this way is obtained the general formulation :

Au = λBu. (3.29)

Let’s insert boundary condition :

15

Page 18: Tesi a.dmytriv

3 – Graetz problem

• f(1) = 0, during the multiplication of a generic matrix M with discrete func-tion f ,its last component 0 is going to be multiplicated with the last column,which can be eliminated, since only zeros will be obtained. The last row ofthe matrix M is usless, because we have the solution on the last knot. Soeliminating both of them we consider only matrice’s part C

[M ]

f1

f2

...fn−1

0

=

∗∗

C ∗...

0 0 ... 0 1

f1

f2

...fn−1

0

.Hence we can extract from A and B only useful components by the simpleinstruction for Matlab:

A=A(1:end-1,1:end-1)B=B(1:end-1,1:end-1)

• f ′(0) = 0, to set this condition we use matrix D1 containing the first derivativeweights ( MD_spline routine). So the first row of A becomes the first row ofD1 and the first row of B becomes zeros:

A(1,:)=D1(1,:)B(1,:)=0

Using created routines , we calculate the eigenvalues and eigenvectors. The figure(3.2) shows that the eigenfunctions converge respecting the conditions fn(0) = 1 andthe fn(1) = 0 , taken to satisfy the temperature condition on the wall T ∗(1, x∗) = 0.Once we have calculated the eigenvalues, we calculate the coefficients using theequation (3.14), where the integral is replaced by sum :

Cn =

∑n0 r∗(1− r∗2)fndr

∗∑n0 r∗(1− r∗2)f 2

ndr∗ . (3.30)

We see that our values differ a little from that calculated by Graetz, where of course,the more we increase the number of points N , the greater is the accuracy. Lookingat the table (3.2) we can compare obtained values, where 150 points where usedfor dicretization of r∗. The next step was the calculation of the temperature usingequation (3.11). In figure (3.3) we can observe the development of temperatureprofiles in a duct, due to a sudden change of temperature on the wall.

The figure (3.5) is nothing but the precedent image magnified in the area im-mediately near the entrance. So we can observe that heat flow near the entrance

16

Page 19: Tesi a.dmytriv

3 – Graetz problem

Table 3.2: Comparison of eigenvalues and coefficients for Graetz problem

n λnGrλn CnGr

Cn −Cnf ′n(1)Gr −Cnf ′n(1)0 2.7043644 2.704359 1.46622 1.47644 1.49758 1.505651 6.679032 6.679164 -0.802476 -0.806399 1.08848 1.091982 10.67338 10.67308 0.587094 0.588643 0.92576 0.929453 14.67108 14.67399 -0.474897 -0.476253 0.83036 0.835904 18.66987 18.67651 0.404402 0.404579 0.76474 0.770145 22.67 22.68 -0.35535 -0.35612 0.71571 0.724336 26.67 26.69 0.31886 0.31825 0.67798 0.684827 30.67 30.70 -0.29049 -0.29094 0.64711 0.657688 34.67 34.71 0.26769 0.2664 0.62119 0.629379 3 38.67 38.73 -0.24890 -0.24901 0.59900 0.61224

is warmer and cools more and more as we move away from it, also note that thetemperature profile is almost rectangular and near the entrance and as it developsit becomes increasingly more parabolic. Instead, the figure(3.4), shows the isolines.The first is the area closest to the entrance and other represent the progressive de-velopment along the duct. Of course there is the cut because we have imposed thatT ∗(r∗, 0) = 1 for all r∗ and therefore our graffic respects this boundary condition.

Figure 3.3: Temperature profiles

17

Page 20: Tesi a.dmytriv

3 – Graetz problem

0 0.2 0.4 0.6 0.8 1 1.2 1.4−1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

x*

r*

Temperature profiles

Figure 3.4: Temperature isolines

Figure 3.5: Temperature profiles near the entrance

18

Page 21: Tesi a.dmytriv

3 – Graetz problem

Finally, we have calculated the local Nusselt numbers using the equation (3.23),where the asymptotes value is 3.656.

0 0.2 0.4 0.6 0.8 13.6

3.8

4

4.2

4.4

4.6

4.8

5

dimensioless axial position x*

Nusse

lt n

um

ber

Figure 3.6

3.4 Scripts used

3.4.1 Calculation of the autofunctions

function [AF avl rs]=AutoFun(N)% restituisce N-1 autofunzioni e N-1 autovalori dell’equazione% rs*f’’ + f’ = - lambda^2 *rs*(1-rs*rs)*f% -A * f = lambda^2 *B * f% f(1) = 0 ; a parete% f’(0) = 0 ; sull’asse del condottoformat long ;rs = linspace(0,1,N) ;MD = MD_spline(rs) ; % calcolo matrici di derivazioneD1 = MD(:,:,1) ; % derivata primaD2 = MD(:,:,2) ; % derivata secondaRS = diag(rs) ; % raggio del condotto adimensionaleA = (RS*D2+D1) ;B = RS-RS^3 ;% Condizioni al contornoA(1,:) = D1(1,:); % in zero f’(0)=0;B(1,:) = 0;A = A(1:end-1,1:end-1); % in L f(L)=0 ;

19

Page 22: Tesi a.dmytriv

3 – Graetz problem

B = B(1:end-1,1:end-1);% estrazione autovalori e autovettori[avt,avl] = eig(-A,B) ; % valuto autovalori e autofunzioniavl = diag(avl) ; % matrice diagonale.[~,ii] = sort(abs(real(avl))); % Ordinamento.avl = avl(ii);avt = avt(:,ii);avl = [sqrt(avl); 0]; % lambda^2AF = zeros(N,N); % allocazione matrice autofunzionifor i=1:N-1

u = [real(avt(1:end,i));0];if (u(1)<0)

u = -u; % inversione del valori negativiendAF(:,i)=u;

end

3.4.2 Calculation of the temperature

% Programma per la soluzione di problema di Graetzclc; close all; clear all; format long;N = 150; % numero dei nodi utilizzati[F avl R] = AutoFun(N); % valuto autovalori e autofunzionim = 148; % numero di autofunzioni utilizzatefigure;plot(R,F(:,1:9)); % plotaggio autofunzionititle(’autofunctions’)ylabel(’f(r*)’)xlabel(’r*=r/ro’)% Calcola i coefficienti Cnc e Cnf’(1):dR=1/(N-1);Cn=zeros(1,m);CnDF=zeros(1,m);for j=1:m

num=0; den=0;for i=1:N-1

dR=R(i+1)-R(i);num=num+( R(i)*(1- R(i)^2))*F(i,j)*dR;den=den+( R(i)*(1- R(i)^2))*(F(i,j))^2*dR;

endCn(j)=num/den ;

20

Page 23: Tesi a.dmytriv

3 – Graetz problem

CnDF(j)=Cn(j)*(F(N,j)-F(N-1,j))/ (R(2)-R(1));end% Calcolo della temperaturaT = zeros(N,N);L = N;z = zeros(1,L);lam = avl;x=(1:L)/1000; % devo usare piccoli valori di x*for k=1:N % ciclo in r

for j=1:Lfor i=1:m/10 % ciclo in lambda

% in questo ciclo si eseque la sommatoria% al variare di n (c,f,lam) avewendo fissato xT(k,j)=T(k,j)+Cn(i)*F(k,i)*exp(-2*x(j)*lam(i)^2);

endend

endT1=T(:,1:L); T2=flipud(T1); T3=[T2;T1];R1=-R;R2=sort(R1);R3=[R2’; R’];figure;plot(T3,R3); xlabel(’x*’);ylabel(’r*’);title(’Temperature profiles’)figure;pcolor(x,R3,T3);title(’Temperature profiles’)xlabel(’x*’);ylabel(’r*’)colorbar;shading interpfigure;pcolor(x,R3,T3);title(’Temperature profiles’)xlabel(’x*’);ylabel(’r*’)colorbar;axis([x(1) x(10) -1 1])shading interp% Calcola il Nusset localeL=100;num=zeros(1,L);den=num;%Nux=num;x=num;for j=1:L % ciclo in x

21

Page 24: Tesi a.dmytriv

3 – Graetz problem

x(j)=j/100;for i=1:m % cicloin lambda% in questo caso si eseque òòa sommatoria al variare% di n(c,f,lam) avendo fissato xnum(j)=num(j)+CnDF(i)*exp(-2*x(j)*lam(i)^2);den(j)=den(j)+(lam(i)^(-2))*CnDF(i)*exp(-2*x(j)*lam(i)^2);end

endNux=num./(2*den);figure;plot(x,Nux,’r’,’markersize’,8); grid onxlabel(’dimensioless axial position x*’); ylabel(’Nusselt number’);

22

Page 25: Tesi a.dmytriv

Bibliography

[1] Carl De Boor, A Pratical Guide to Splines , Springer (1994).[2] R.Haberman, Applied Partial Differential Equations, Pearson Prentice Hall (4th

ed.)(2004).[3] Frank M. White , Viscous fluid flow, Inc McGraw-Hill (1991)

23