temperature distribution in a ground section of a double-pipe system in a districti heating network

43
Politecnico di Torino Mechanical Engineering Numerical Modelling Report Academic year 2010/2011 TEMPERATURE DISTRIBUTION IN A GROUND SECTION OF A DOUBLE-PIPE SYSTEM IN A DISTRICT HEATING NETWORK Paolo Fornaseri Enrico Grassano Alessandro Tumino

Upload: paolo-fornaseri

Post on 05-Dec-2014

146 views

Category:

Engineering


5 download

DESCRIPTION

Our analysis concerns the distribution network of a suburb in the city of Turin. We analyzed the thermal needs, the network layout and many other engineering problems regarding the distribution of heat. In the following report we are going to analyze the simplified model of a couple of buried ducts, conveying the fluid used for thermal needs in the houses. We analyzed the thermal distribution in the pipeline, in particular we focused on a section of the ground, in which the water passes through the double-pipe system, namely return and supply pipe. We used the fundamental heat equation (conduction) and the subsequent numerical discretization, in the transient and in the steady state. To this aim, we made some simplifications in order to apply our mathematical model.

TRANSCRIPT

Page 1: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

Politecnico di Torino Mechanical Engineering

Numerical Modelling Report Academic year 2010/2011

TEMPERATURE DISTRIBUTION

IN A GROUND SECTION

OF A DOUBLE-PIPE SYSTEM

IN A DISTRICT HEATING NETWORK

Paolo Fornaseri

Enrico Grassano

Alessandro Tumino

Page 2: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

1

INDEX ....................................................................................................................................................................... 0

....................................................................................................................................................................... 1

Introduction .................................................................................................................................................. 2

Mathematic model description: the heat equation .................................................................................. 2

Boundary conditions for the thermal model ......................................................................................... 4

Finite elements method theory .................................................................................................................. 5

Time discretization .................................................................................................................................. 6

Geometry and boundary conditions.......................................................................................................... 7

Physical Parameters ................................................................................................................................... 9

Temperature profile ................................................................................................................................... 10

Mesh and its Refinement .......................................................................................................................... 11

n_mesh parameter ............................................................................................................................. 11

Standard Refinement ......................................................................................................................... 12

“Manual” Refinement ......................................................................................................................... 12

Particular Case (Mesh for ODE45) .................................................................................................... 13

Computation Time in function of Triangle size ............................................................................... 14

Mesh quality ....................................................................................................................................... 15

Matrix and vectors computations ............................................................................................................ 18

Stiffness matrix ...................................................................................................................................... 18

Right hand side vector .......................................................................................................................... 18

Mass matrix ............................................................................................................................................ 18

Initial Solution ............................................................................................................................................ 19

Stationary solution .................................................................................................................................... 19

Time advancing ......................................................................................................................................... 20

Linear system solution method ............................................................................................................... 21

Time comparison ....................................................................................................................................... 22

Results ........................................................................................................................................................ 23

ODE time advancing method ................................................................................................................... 29

Conclusions ............................................................................................................................................... 32

Appendix .................................................................................................................................................... 33

Page 3: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

2

Introduction

Our analysis concerns the distribution network of a suburb in the city of Turin.

We analyzed the thermal needs, the network layout and many other engineering problems regarding

the distribution of heat.

In the following report we are going to analyze the simplified model of a couple of buried ducts,

conveying the fluid used for thermal needs in the houses.

We analyzed the thermal distribution in the pipeline, in particular we focused on a section of the

ground, in which the water passes through the double-pipe system, namely return and supply pipe.

We used the fundamental heat equation (conduction) and the subsequent numerical discretization, in

the transient and in the steady state.

To this aim, we made some simplifications in order to apply our mathematical model.

Mathematic model description: the heat equation

The domain in which we are working is the cross section of the soil that hence becomes the plate studied at lesson. The heat quantity in the plate is expressed like:

∫ 𝑐(𝑥)𝜌(𝑥)𝑢(𝑥, 𝑡)𝑑𝑥

where: c is the heat capacity ρ is the mass density per unit surface u is the temperature This integral has to be performed on the whole surface. Now, having a heat transfer balance on the plate boundary it can be written that:

𝑑

𝑑𝑡∫ 𝜌𝑐𝑢 𝑑𝑥 = ∫ 𝛷 ∙ 𝑛 𝑑𝑠

where Φ is the heat flux n is the unit vector normal to the boundary Now, we can use the Gauss-Green theorem and we get:

∫ 𝑐𝜌𝑑𝑢

𝑑𝑡𝑑𝑥 = ∫ ∇ ∙ 𝛷 𝑑𝑥

Hence

𝑐𝜌𝑑𝑢

𝑑𝑡− ∇ ∙ 𝛷 = 0

the Fourier relation, linking the heat flux to the temperature gradient, is now introduce. Substituting in the previous relation we get :

Page 4: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

3

𝑐𝜌𝑑𝑢

𝑑𝑡− ∇ ∙ (𝜆∇𝑢) = 0

Where λ is the thermal conductivity. The relation holds for every point in the domain of the plate. The stationary heat equation is:

∇ ∙ (𝜆∇𝑢) = 0

Actually, the most general relation includes the forcing term q, namely, the heat absorbed or sold by the system. In our model there’s no the need to include this term, since no external source of heat is considered.

Page 5: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

4

Boundary conditions for the thermal model In the model we dealt with, we considered three kind of boundary condition:

Dirichlet boundary, so the direct imposition of a certain value of temperature on the

boundary

𝑢 = 𝑔

Neumann conditions, so fixing the value of the derivative, with respect to a certain

direction, of the temperature. This is the same as impose a flux

𝜕𝑢

𝜕𝑛= 𝜓

Robin condition that consists in the expression of the flux like a function of the

temperature

𝜕𝑢

𝜕𝑛= 𝛼(𝑇∞ − 𝑢)

where T∞ is the known temperature outside and α is the convective heat transfer

coefficient.

Page 6: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

5

Finite elements method theory

We introduce now the finite element model for the previous equation.

We discretize the domain considered a triangulation τ, given by a sum of triangles T such that:

𝑈𝑇∈𝜏 = Ω

First of all, we have to bring back the previous formulation to the following one:

{𝜚

𝜕𝑢

𝜕𝑡− ∇ ∙ (𝜇∇𝑢) = 𝑓

𝑏. 𝑐. 𝑜𝑛 𝑡ℎ𝑒 𝑠𝑢𝑟𝑓𝑎𝑐𝑒

So, new coefficients are obtained from the previous values with the following formulas:

𝜇 =𝜆

𝑐

𝑓 =𝑞

𝑐

The latter one, as said, is nil.

Now, we consider the variational formulation of the problem

{

𝑢ℎ(𝑡) ∈ 𝑉ℎ

∫ 𝜌𝜕𝑢ℎ

𝜕𝑡𝑣ℎ𝑑𝑥 + ∫ 𝜇∇𝑢ℎ∇𝑣ℎ𝑑𝑥 = 0

Where the function v is the generic test function.

In this scheme, the function vh is generated by linear combination of the Lagrange base

functions φj, such that:

𝑣ℎ = ∑ 𝑣𝑗𝜑𝑗

𝑁

𝑗=1

Now, for the variable u it holds:

𝑢ℎ = ∑ 𝑣𝑘(𝑡)𝜑𝑘

𝑁

𝑘=1

And so finally we obtain:

∑ 𝑢�̇� ∫ 𝜌𝜑𝑗𝜑𝑘 𝑑Ω

𝑘

+ ∑ 𝑢𝑘

𝑘

𝜇 ∫ ∇𝜑𝑗∇𝜑𝑘 𝑑Ω = 0

The method is based on the projection of the weak form of a differential equation on functions with limited support The base functions 𝜑𝑗 are pyramidal functions with a vertex in xj, height equal to 1

and base made by the triangles TK having a vertex in xj.

Page 7: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

6

Time discretization

Since we have to consider the temporal variation, we used different time advancing methods.

To this aim, it’s good to define the matrix quantities that will be used in the system:

𝑀𝑢′ − 𝐴𝑢 = 0

hence, it holds:

𝑀 = (𝑚𝑗𝑘) = ∫ 𝜌𝜑𝑗𝜑𝑘 𝑑Ω

and

𝐴 = (𝑎𝑗𝑘) = 𝜇 ∫ ∇𝜑𝑗∇𝜑𝑘 𝑑Ω

The considered time advancing methods are:

Explicit Euler

Implicit Euler

Crank-Nicolson

The second and third methods do not require particular care about the Δt, namely the

advancing step, while the first one is requiring that:

∆𝑡 ≤2

|𝜆𝑚𝑎𝑥|

where λmax is the biggest eigenvector or the matrix M-1A.

Page 8: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

7

Geometry and boundary conditions

The geometry and the boundary conditions are here summarized:

Pipes: Non homogeneous Dirichlet BCs. The temperature of the metal of the pipes is

simply given by the temperature of the water which passes inside them;

Lateral Boundaries: homogeneous Neumann BCs, assuming nil heat flux;

Lower Boundary: here we imposed Robin BC, instead more obvious Dirichlet in order to

represent the heat flux due to the soil moisture;

Upper Boundary: Robin BC, considering air convection. Heat is continuously dissipated

and the temperature tends to a certain value (environment temperature).

The temperature of the ground below the pipes is assumed as in function of the one of

the environment, but with some distinctions in function of the value of this temperature.

If it is below the average of the period, the temperature of the ground is taken a little

higher than this one, while if it is over the average, this temperature is taken a little

lower. Besides, the temperature of the pipes is taken as the mean of these two

temperatures.

Page 9: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

8

Moreover, when implemented on Matlab, continuity between shapes is needed, indeed at the

interface ground/pipes continuity was imposed between the external side of the circles and the

side of the hole of the rectangle.

Here below the most important geometric values are reported. These are the ones taken from

our advanced engineering thermodynamics project. Though, in the program these values can

be decided by the user (all but centers distance and depth).

From thermodynamic report Supply Return

Pipe thickness mm 5 10

Inner diameter mm 40 40

Outer diameter mm 50 60

Centers distance m 0.5

Depth m 0.5

Water Temperature °C 90 40

Page 10: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

9

Physical Parameters

Some considerations have to be done about the physical parameters. In particular the insulator thermal conductivity has been chosen higher than the real one.

Indeed the mineral wool has a conductivity of 0.047 W/mK while in this case we chose 5 W/mK,

This was done to avoid a sharp drop in temperature distribution between the pipe and the

ground but a slighter gradient. However the presence of the thin metal wall of the pipe in

reality increases slightly the conduction. We did the same consideration for the ground

conductivity, in order to get a prettier result.

Another parameter has to be mentioned is the surface density. In this case, since a thickness

couldn’t to be defined (2D problem), the value of the real volumetric density was adopted also

for the surface density.

Finally the Robin BC requires the definition of the convection heat transfer coefficient. The one

chosen for the air side is αair = 20 W/m2K (typical value), whereas for the soil moisture αsoil = 10

W/m2K (guessed value).

Here below all the physical parameters used in the calculations are reported.

Parameter Symbol Unit Value

Insulator thermal conductivity

λins W/mK 5

Ground thermal conductivity

λg W/mK 30

Outside air temperature (winter average)

T∞ °C 8

Deep Ground temperature T∞2 °C 7

Convection - Air side αair W/m2

K 20

Convection - Deep Ground Side

αsoil W/m2

K 10

Insulation surface density ρins kg/m2 20

Ground surface density ρg kg/m2 2000

Insulation specific heat capacity

cins J/kgK 500

Ground specific heat capacity

cg J/kgK 1480

External thermal power q W/m2 0

Page 11: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

10

Temperature profile

The temperature profile for the rising temperature in the pipelines (the metal takes 60 seconds to reach the water temperature):

These profiles are for:

Supply temperature = 90°C;

Return temperature = 40°C;

Starting Ground temperature = 8° C

0 1 2 3 4 5 60

10

20

30

40

50

60

70

80

90

Time [s]

Edge 1

tem

pera

ture

[°C

]

Temperature Growth in the Pipes at the Switch ON

Page 12: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

11

Mesh and its Refinement

The reliability of the solution depends on how the problem is discretized, and so on the mesh quality.

n_mesh parameter An important parameter from which depends the quality of the mesh is the number of sides of the polygons which render the circular shapes of the two pipes. Again, since the diameters of the pipes can vary, this value is function of these diameters.

n_meshret=n_mesh+ceil(retdiam*4*n_mesh) n_meshsupp=n_mesh+ceil(suppdiam*4*n_mesh)

These functions to determine the n_mesh values are simply an example of the ones that

could be used to obtain an n_mesh growing with the size of the pipes.

The starting value n_mesh is function of the desired quality of the mesh. The user in our

program has three choices: 4, 16, 32.

Page 13: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

12

Talking about refinement, we tried to use different methods and levels of refinement in order to get a good compromise between computation time and quality of the solution.

Standard Refinement Introducing a third value (a scalar, in the example below equal to 0.05) in the use of the mesh function it is possible to decide the level of the refinement.

Me=Mesh(Sh,Bc,0.05)

Here below there is a figure representing the mesh made with the previous command,

with n_mesh = 16.

“Manual” Refinement Passing a function of x and y through the InRect function, it is possible to drive the refinement towards specific zones. In our case obviously the important parts are the pipes and the insulations.

Raf=@(x,y)0.1-0.08*(InRect([x,y],[0.5 0.5],[

(0.1+retdiam+retins*2) (0.1+retdiam+retins*2)])|InRect([x,y],[1

0.5],[ (0.1+suppdiam+suppins*2) (0.1+suppdiam+suppins*2)])); Me=Mesh(Sh,Bc,Raf);

The parameters of the InRect function are the coordinates of the centers of the pipes

which represent the centers of the rectangular zones (in our case square zones since a

square approximates a circle better than a rectangle), and the width and the height of

these ones. Since in the last version of our program the dimensions of the pipes can be

0 0.5 1 1.50

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1Mesh

Page 14: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

13

chosen by the user, the side of the square is function of pipes diameters and insulator

thicknesses.

The refinement is showed in the following figure (n_mesh = 16):

Particular Case (Mesh for ODE45) Since computations for ODE functions are very heavy, we decide to let the user choose a very rough discretization in order to make this functions work even with high inspection times (40000 s, that are indeed necessary to reach the stationary solution). Of course this is only a trick to obtain anyway a solution of ODE45 with our CPUs. The mesh is quite ridiculous (made of 148 nodes). For example the circular pipes are discretized as hexagons (n_mesh = 6).

0 0.5 1 1.50

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1Mesh

0 0.5 1 1.50

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1Mesh

Page 15: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

14

Computation Time in function of Triangle size

The time required to calculate the mesh depends on the geometry and on the triangle

maximum side’s size. Here below both the number of triangles and the time for mesh

calculation vs the side’s sizes are reported, as we can see the trends are proportional.

Page 16: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

15

Mesh quality

Here the plot of the mesh quality for different cases is reported. As expected, the lower the triangle side’s size higher the quality, even though it is not very high in some triangles at the interface between pipes and ground.

Figure 1 - Low Mesh Quality - Standard Refinement (1) - 148 nodes

Figure 2- Standard Mesh Quality - Standard Refinement (0.05) - 1230 nodes

0 0.5 1 1.50

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1Mesh quality

0.7

0.75

0.8

0.85

0.9

0.95

0 0.5 1 1.50

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1Mesh quality

Page 17: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

16

Figure 3- High Mesh Quality - Standard Refinement (0.05) - 1919 nodes

Figure 4 - Standard Mesh Quality - Manual Refinement - 1208 nodes

0 0.5 1 1.50

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1Mesh quality

0 0.5 1 1.50

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1Mesh quality

Page 18: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

17

Figure 5 - High Mesh Quality - Manual Refinement - 1909 nodes

Figure 6 - High Mesh Quality - Manual Refinement - 1909 nodes (Zoom)

As we can see lower the side higher the mesh quality. As explained before, we chose the mesh

refinement related to the best quality.

0 0.5 1 1.50

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1Mesh quality

0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8

0.5

0.55

0.6

0.65

0.7

Mesh quality

0.65

0.7

0.75

0.8

0.85

0.9

0.95

Page 19: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

18

Matrix and vectors computations

Stiffness matrix

As said before the system to be solved is: 𝑀𝑢′ + 𝐴𝑢 = 𝑏

Where M is the mass matrix, A the stiffness matrix and b the right-hand side vector, in our case

represented only by the boundary conditions because the external forcing is nil.

Since there is a mixture of boundary conditions we had to compose a proper function that

could manage this variety of conditions. Therefore we combined the function

AssemblaDiffRobin with the Function AsssemblaDiffNOm (we called it

AssemblaDiffNOmRobin2).

The stiffness matrix is the standard one, modified only in the Robin boundary nodes.

Right hand side vector

The computation of the elements in the vector b was done by assembling the following three

parts: % bRobin : part of b vector due to Robin BCs % b1 : part of b vector due to Dirichlet BCs on Return Pipe % b2 : part of b vector due to Dirichlet BCs on Supply Pipe

Even though the temperatures of the metallic surface of the pipes are 40 and 90°C, the Dirichlet boundary conditions in the main program are imposed for 1°C. This choice is driven by the need of having a b vector versatile in function of the temperature during the time advancing analysis (In the switching on of the system, the temperature of the metal increases from the environment temperature to the water temperature). In fact in this way is sufficient to multiply at each time step the part of b vector related to a certain pipe for the effective temperature of that pipe. Each pipe needs a different part of b vector since the growth in temperature and the final temperature are different. To assign the right value of b to a certain node equation, we need to use the function

Me.DirichletNodes(-jj,2)==3

(3 is the number of the shape, in this case we are searching the Dirichlet Nodes of the Supply Pipe)

On the contrary, the part of the b vector related to Robin Boundary does not depend on the temperatures in the pipes and keeps constant during the time advancing analysis.

Mass matrix

No particular modifications are needed in this case since it does not depend on the boundary conditions. We simply used the function “AssemblaMatriceMassa”.

Page 20: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

19

Initial Solution

The initial solution is obtained solving the following system

𝐴𝑢(𝑡 = 0)

in which A is the Stiffness Matrix, and b is the one for the temperature in the pipes at t=0 (Tsupply=Tsoil=8°C).

Stationary solution

The Stationary solution is obtained solving the same system, but considering the steady state (t∞) temperature for the pipes (Tsupply=90°C, Treturn=40°C):

𝐴𝑢 = 𝑏(𝑡 → ∞)

Page 21: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

20

Time advancing

The dynamic solution is obtained by solving the system of differential equations:

𝑀𝑢′ + 𝐴𝑢 = 𝑏 → 𝑢′ = −𝑀−1𝐴𝑢 + 𝑀−1𝑏

As time advancing method different choices can be done.

In our assignment we decided to analyze the following ones:

1) Explicit Euler;

2) Implicit Euler;

3) Crank-Nicholson.

As known from theory, in the first one there’s a restriction on the time step, indeed:

∆𝑡𝑚𝑎𝑥 =2

|𝜆𝑚𝑎𝑥|

Where λmax is the maximum eigenvalue of the matrix M-1A, in Matlab: lambda_max=max(eigs(inv(M)*A))); and tis value is, for the default Mesh refinement (the rougher one) is:

|𝜆𝑚𝑎𝑥| = 1047.75

So

∆𝑡𝑚𝑎𝑥 = 0.0019 𝑠

Since we observed that our system reaches the stationary solution in 40000 s; this method has

not been applied, because it would have required too much time, for that time step.

Hence we applied only the last two advancing method, that have no constraints on the time

step.

Page 22: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

21

Linear system solution method

To solve the linear system the conjugate gradient was adopted. This method was also

integrated with preconditioning by using LU and Cholensky incomplete factorizations and so

obtaining the Preconditioned Conjugate Gradient Method (pcg).

Here below the trends of the relative residuals vs the iteration step are reported, for the

combinations advancing method/preconditioner. Obviously the minimum value is the same for

all these combinations, since the same tolerance was imposed, the things that change is the

slope, namely the velocity of solution converging.

As we can see from this plot the preconditioned methods converge in less number of steps and

implicit Euler method (EI) is faster than Crank-Nicholson (CK) one.

0 20 40 60 80 100 12010

-8

10-6

10-4

10-2

100

102

104

iteration number

rela

tive r

esid

ual

Methods Comparison

IE - No PreC

IE - LU PreC

IE - Ch PreC

CK - No PreC

CK - LU PreC

CK - Ch PreC

Page 23: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

22

Time comparison The table here reported shows the main results of the various combinations between

advancing method and preconditioning. The EI method with Cholensky incomplete factorization

turns out to be the faster one, whereas the not preconditioned solutions require more time.

Advancing Method Preconditioning Time cond(M-1A)

Implicit Euler No prec. 6,38 200,28

LU 6,24 56,94

Cholensky 1,25 56,94

Crank-Nicholson No prec. 8,54 162,31

LU 4,17 38,48

Cholensky 4,31 38,48

Page 24: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

23

Results

Below we are going to expose the results for our preferred geometry, but must be remembered that in this program there are a few degrees of freedom in the choice of the system. They are obtained by considering the refined mesh (localized “manual” refinement) with standard n_mesh (around 23). Geometry:

Mesh:

0 0.5 1 1.50

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1Geometry

Shape 1

Shape 2

Shape 3

0 0.5 1 1.50

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1Mesh

Page 25: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

24

Mesh Quality:

Initial Solution:

0 0.5 1 1.50

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1Mesh quality

0.75

0.8

0.85

0.9

0.95

0

0.5

1

1.5

0

0.5

10

2

4

6

8

10

Initial Solution

Page 26: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

25

Stationary Solution:

Crank Nicholson not preconditioned Time Advancing Solution @ 30 s (pipes temperatures still increasing):

0

0.5

1

1.5

0

0.2

0.4

0.6

0.8

1

0

20

40

60

80

100

Stationary solution

0

0.5

1

1.5

0

0.5

10

20

40

60

80

100

Time Advancing

Page 27: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

26

Time Advancing Solution @ 300 s (growth in pipes finished):

Time Advancing Solution @ 15000 s (intermediate situation, temperature of the ground is growing):

0

0.5

1

1.5

0

0.5

10

20

40

60

80

100

Time Advancing

0

0.5

1

1.5

0

0.5

10

20

40

60

80

100

Time Advancing

Page 28: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

27

Difference between steady state profile temperature and final values with time advancing @15000 s:

Time Advancing Solution @ 40000 s (equilibrium is reached):

0

0.5

1

1.5

0

0.5

1-4

-3

-2

-1

0

0

0.5

1

1.5

0

0.5

10

20

40

60

80

100

Time Advancing

Page 29: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

28

Difference between Stationary Solution and Time Advancing Solution @ 40000 s

On the results obtained we can say that they are reliable, because the temperature, fixed at

pipes internal side (Dirichlet condition) decreases with a strong gradient around the edge of the

tube and gradually on the soil. The temperature is also affected by convection with the outside

world as visible from the inclination of the distribution in the soil side subject to the Robin

boundary condition.

Also the time needed to reach the stationary solution is realistic (40000 s ≈ 10 h).

0

0.5

1

1.5

0

0.5

1-0.15

-0.1

-0.05

0

0.05

0.1

Page 30: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

29

ODE time advancing method

We applied also the function ODE45 to solve our problem.

In this function the time step is very small (≈10-4 s) and cannot be modified by the user.

Since it couldn’t be solved in a reasonable time with a high quality mesh, we used a rougher

mesh (148 nodes) to have the solution until the steady state solution without the need of

waiting hours. Here below some plots, for different time interals are reported, and the

difference between ODE45 and Crank-Nicholson method is shown.

0

0.5

1

1.5

0

0.5

10

20

40

60

80

100

t= 200

0

0.5

1

1.5

0

0.5

1-40

-30

-20

-10

0

Difference between time advancing and ODE45

Page 31: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

30

0

0.5

1

1.5

0

0.5

10

20

40

60

80

100

t= 10000

0

0.5

1

1.5

0

0.5

1-10

-8

-6

-4

-2

0

Difference between time advancing and ODE45

Page 32: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

31

00.5

11.5

0

0.2

0.4

0.6

0.8

1

0

20

40

60

80

100

t= 40000

0

0.5

1

1.5

0

0.5

1-4

-2

0

2

4

6

x 10-3

Difference between time advancing and ODE45

Page 33: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

32

Conclusions

Of course the results depend mainly on the properties of insulation and of the ground. Since we

took very high values of conductivity to let the gradient be evident, the results are not so “real”.

For example the temperature in the ground near the pipes is increased of about 20-30°C (and it

is quite unlikely).

Anyway tuning these parameters to the real one, the results seem reliable.

The difference between time advancing method at t∞ is negligible, so the two results

confirm their reliability each other.

Finally the refinement of the mesh has not a strong influence on the results, even though the

quality results to be slightly better, but it has deep effects in computation time.

In the following appendix the scripts are reported

Page 34: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

33

Appendix

Main Program (file PROGRAMMA.m)

The following is the main program used for all the calculations discussed. It is

divided in sections and it allows to the user to set the input parameter inside the

ground section. Moreover the user can choose what to evaluate and with which

method. This programs make use of a lot of function inside the foder

05ElementiFiniti2D that must be added to the path. In particular, as said in the

previous chapter the functions AssemblaDiffNOm and AssemblaDiffRobin have

been coupled in the function AssemblaDiffNOmRobin2, that is showed at the end

of the appendix.

clear all close all

%% Physical Parameters (g=ground; s=supply ;r=return) rhog=2000; %kg/m3 density cg=1480; %J/kgK specific heat capacity kg=30; %W/mK thermal conductivity mhug=kg/cg; rhos=20; %kg/m3 density cs=500; %J/kgK specific heat capacity ks=5;%W/mK thermal conductivity mhus=ks/cs; rhor=20; %%kg/m3 cr=500; %J/kgK specific heat capacity kr=5;%W/mK thermal conductivity mhur=kr/cr; alfaair=20; %%W/m2K air conductivity alfasoil=10; %% Temperatures in the Pipes

disp('Temperature in the Supply Line'); tsupp=input('Supply Temperature:');

disp('Temperature in the Return Line'); tret=input('Return Temperature:');

disp('Temperature of the Enviroment'); tenv=input('Enviroment Temperature:');

%% Pipes Diameters

disp('Supply Pipe Diameter (m)'); suppdiam=input('Supply Diameter(suggested value 0.1):');

disp('Return Pipe Diameter (m)');

Page 35: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

34

retdiam=input('Return Diameter(suggested value 0.1):');

%% Insulator Thickness

disp('Insulator Thickness in the Supply Line (m)'); suppins=input('Supply Insulation(suggested value 0.1):');

disp('Insulator Thickness in the Supply Line (m)'); retins=input('Return Insulation(suggested value 0.05):');

%% Quality of the Mesh

disp('Quality of the Mesh'); disp('1 - Low (for quite high t_end in ODE solving)'); disp('2 - Standard'); disp('3 - High');

qual=input('Quality (2 default value):');

if qual==1 n_mesh=4; elseif qual==3 n_mesh=32; else n_mesh=16; end

%% Geometry n_meshret=n_mesh+ceil(retdiam*4*n_mesh) n_meshsupp=n_mesh+ceil(suppdiam*4*n_mesh) Sh(2)=Circle([0.5 0.5],retdiam/2+retins,n_meshret)-Circle([0.5

0.5],retdiam/2,n_meshret); %%return pipe insulation Sh(3)=Circle([1 0.5],suppdiam/2+suppins,n_meshsupp)-Circle([1

0.5],suppdiam/2,n_meshsupp);%%supply pipe insulation Sh(1)=Rect([0.75 0.5], [1.5 1])-Circle([0.5 0.5],retdiam/2+retins,n_meshret)-

Circle([1 0.5],suppdiam/2+suppins,n_meshsupp);%-Circle([1 0.5],0.02,n_mesh)-

Circle([0.5 0.5],0.02,n_mesh);%%soil Sh(1) = set(Sh(1), 'alfa',mhug, 'density', rhog); Sh(2) = set(Sh(2), 'alfa',mhur, 'density', rhor); Sh(3) = set(Sh(3), 'alfa',mhus, 'density', rhos);

%% Boundary Conditions

%Robin coefficients hair=alfaair/kg; hsoil=alfasoil/kg;

if tenv>7 Tinf=tenv+1;

Tinf2=tenv-1;

elseif tenv>0 Tinf=tenv; Tinf2=tenv; else Tinf=tenv-1;

Page 36: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

35

Tinf2=tenv+1;

end

g=alfaair*Tinf/kg; g2=alfasoil*Tinf2/kg;

Bc=Boundary(Sh);

Bc(1).Polygons(1).Edge(1)=Robin(hsoil,g2); Bc(1).Polygons(1).Edge(4)=Neumann(0); Bc(1).Polygons(1).Edge(2)=Neumann(0);

Bc(2).Polygons(2).Edge(:)=Dirichlet(1); Bc(3).Polygons(2).Edge(:)=Dirichlet(1); Bc(2).Polygons(1).Edge(:)=Continuity(); Bc(3).Polygons(1).Edge(:)=Continuity(); Bc(1).Polygons(2).Edge(:)=Continuity(); Bc(1).Polygons(3).Edge(:)=Continuity(); Bc(1).Polygons(1).Edge(3)=Robin(hair,g);

figure(1) title('Geometry') Draw(Sh,Bc)

%% Mesh

disp('Mesh Refinement'); disp('1 - Standard Refinement (integrated function)'); disp('2 - Manual Refinement around the pipes');

ref=input('Refinement Method:');

if ref==1

disp('Do you want to inspect the time needed for different levels of

refinement?'); disp('1 - No'); disp('2 - Yes');

tan=input('Refinement Method:');

if tan==2 lato=[0.02,0.05,0.1,0.2,0.3,0.5]; for k=1:6, tic; Me=Mesh(Sh, Bc, lato(k)); time(k)=toc; tr(k)=length(Me.Triangles); end figure(8); title('Mesh Refinement Time'); subplot(2,1,1); semilogy(lato,tr); xlabel('Maximum side [A.U.]'); ylabel('Time [s]'); ylabel('Triangles');

Page 37: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

36

subplot(2,1,2); semilogy(lato,time); xlabel('Maximum side [A.U.]'); ylabel('Time [s]'); ylabel('Time [s]');

end if qual==1 Me=Mesh(Sh,Bc,1); else Me=Mesh(Sh,Bc,0.05); end

else Raf=@(x,y)0.1-0.08*(InRect([x,y],[0.5 0.5],[ (0.1+retdiam+retins*2)

(0.1+retdiam+retins*2)])|InRect([x,y],[1 0.5],[ (0.1+suppdiam+suppins*2)

(0.1+suppdiam+suppins*2)])); Me=Mesh(Sh,Bc,Raf); end

figure(2)

Draw(Me);

title('Mesh');

figure(11)

Draw(Me,'quality') title('Mesh quality');

%% Matrices Computations [A,bRobin,b1,b2 ]=AssemblaDiffNOmRobin2(Me); M=AssemblaMatriceMassa(Me); uu=zeros(size(Me.Coordinates,1),1); tson=60; %switch on time Temp2=@(t)tenv+((tret-tenv)/tson)*min(t,tson); Temp3=@(t)tenv+((tsupp-tenv)/tson)*min(t,tson); t=linspace(0,80,100); figure(3)

plot(t,Temp2(t),t,Temp3(t)); xlabel('Time [s]'); ylabel('Edge 1 temperature [°C]') grid on;

title ('Temperature Growth in the Pipes at the Switch ON');

lato2=find(Me.UnknownNodes<0 & Me.Coordinates(:,1)<(0.51+retdiam/2+retins)&

Me.Coordinates(:,2)>(0.49-retdiam/2-retins)); lato3=find(Me.UnknownNodes<0 & Me.Coordinates(:,1)>(1-suppdiam/2-suppins)&

Me.Coordinates(:,2)>(0.49-suppdiam/2-suppins));

Page 38: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

37

uu(lato2)=tenv; uu(lato3)=tenv;

lato4=GetDirichletNodes(Me,[1,1,1]); uu(lato4)=Evaluate(Bc,[1,1,1],Me.Coordinates(lato4,:)); uutadv=uu;

%% Precond disp('Do you want to evaluate the conditioning number?'); disp('0 - No'); disp('1 - Yes'); precond=input('Preconditioning:');

if precond==1 dt=200; Mck=M+(dt/2*A); Mei=M+dt*A; disp('Preconditiong methods for implicit euler (ei) or crank nicholson (ck)

method:'); disp('1 - LU incomplete factorization'); disp('2 - Cholensky incomplete factorization'); disp('3 - No preconditioning'); pre=input('Preconditioning:'); if pre==1 [Lei,Uei]=luinc(sparse(Mei),'0'); ncondei=condest(Lei*Uei\sparse(Mei)); [Lck,Uck]=luinc(sparse(Mck),'0'); ncondck=condest(Lck*Uck\sparse(Mck)); elseif pre==2 [Uei]=cholinc(sparse(Mei),'0'); Lei=Uei'; ncondei=condest((Lei*Uei)\sparse(Mei)); [Uck]=cholinc(sparse(Mck),'0'); Lck=Uck'; ncondck=condest((Lck*Uck)\sparse(Mck)); else ncondei=condest(Mei); ncondck=condest(Mck); end

disp('computation time: '); disp('conditioning number'); ncondck ncondei

end

%% Tolerance Plot disp('Do you want to evaluate how fast Tolerance is reached?'); disp('0 - No'); disp('1 - Yes'); tolflag=input('Tolerance:');

if tolflag==1 uT0=pcg(A,bRobin+b1*Temp2(0)+b2*Temp3(0),1e-3,100); u=uT0; tend=40000; dt=200;

tic

Page 39: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

38

for k11=1:tend/dt t=k11*dt; %[u,flag,relres,iter,resvec]=pcg((M+dt2/2*A), (M*u-

dt2/2*A*u+dt2/2*((bRobin+b1*Temp2(t)+b2*Temp3(t))+(bRobin+b1*Temp2(t-

dt2)+b2*Temp3(t-dt2)))),1e-12,200,[],[],u);%Crank-Nicholson

[u,flag,relres11,iter11,resvec11]=pcg((M+dt*A),(M*u+dt*(bRobin+b1*Temp2(t)+b2

*Temp3(t))),1e-10,200,[],[],u); end time(1)=toc;

Mie=M+(dt*A); [L,U]=luinc(sparse(Mie),'0'); tic for k12=1:tend/dt t=k12*dt; %[u,flag,relres,iter,resvec]=pcg((M+dt2/2*A), (M*u-

dt2/2*A*u+dt2/2*((bRobin+b1*Temp2(t)+b2*Temp3(t))+(bRobin+b1*Temp2(t-

dt2)+b2*Temp3(t-dt2)))),1e-12,200,[],[],u);%Crank-Nicholson

[u,flag,relres12,iter12,resvec12]=pcg((M+dt*A),(M*u+dt*(bRobin+b1*Temp2(t)+b2

*Temp3(t))),1e-10,200,L,U,u); end time(2)=toc;

Mck=M+(dt/2*A); R=cholinc(sparse(Mck),'0'); tic for k13=1:tend/dt t=k13*dt; %[u,flag,relres,iter,resvec]=pcg((M+dt2/2*A), (M*u-

dt2/2*A*u+dt2/2*((bRobin+b1*Temp2(t)+b2*Temp3(t))+(bRobin+b1*Temp2(t-

dt2)+b2*Temp3(t-dt2)))),1e-12,200,[],[],u);%Crank-Nicholson

[u,flag,relres13,iter13,resvec13]=pcg((M+dt*A),(M*u+dt*(bRobin+b1*Temp2(t)+b2

*Temp3(t))),1e-10,200,R',R,u); end time(3)=toc;

tic for k=1:tend/dt t=k*dt; [u,flag,relres21,iter21,resvec21]=pcg((M+dt/2*A), (M*u-

dt/2*A*u+dt/2*((bRobin+b1*Temp2(t)+b2*Temp3(t))+(bRobin+b1*Temp2(t-

dt)+b2*Temp3(t-dt)))),1e-10,200,[],[],u);%Crank-Nicholson %

[u,flag,relres,iter,resvec]=pcg((M+dt*A),(M*u+dt*(bRobin+b1*Temp2(t)+b2*Temp3

(t))),1e-10,200,[],[],u); end time(4)=toc;

tic for k=1:tend/dt t=k*dt; [u,flag,relres22,iter22,resvec22]=pcg((M+dt/2*A), (M*u-

dt/2*A*u+dt/2*((bRobin+b1*Temp2(t)+b2*Temp3(t))+(bRobin+b1*Temp2(t-

dt)+b2*Temp3(t-dt)))),1e-10,200,L,U,u);%Crank-Nicholson %

[u,flag,relres,iter,resvec]=pcg((Mie+dt*A),(Mie*u+dt*(bRobin+b1*Temp2(t)+b2*T

emp3(t))),1e-10,200,L,U,u); end

Page 40: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

39

time(5)=toc;

tic for k=1:tend/dt t=k*dt; [u,flag,relres23,iter23,resvec23]=pcg((M+dt/2*A), (M*u-

dt/2*A*u+dt/2*((bRobin+b1*Temp2(t)+b2*Temp3(t))+(bRobin+b1*Temp2(t-

dt)+b2*Temp3(t-dt)))),1e-10,200,R',R,u);%Crank-Nicholson %

[u,flag,relres,iter,resvec]=pcg((Mck+dt*A),(Mck*u+dt*(bRobin+b1*Temp2(t)+b2*T

emp3(t))),1e-10,200,R',R,u); end time(6)=toc;

figure(12) semilogy(0:iter11,resvec11,'-o') hold on semilogy(0:iter12,resvec12,'-x') hold on semilogy(0:iter13,resvec13,'-r') hold on semilogy(0:iter21,resvec21,'-g') semilogy(0:iter22,resvec22,'+') semilogy(0:iter23,resvec23,'--rs') legend('IE - No PreC','IE - LU PreC','IE - Ch PreC','CK - No PreC','CK - LU

PreC','CK - Ch PreC')

xlabel('iteration number'); ylabel('relative residual');

title('Methods Comparison');

end

%% Initial Solution (t=0) uT0=pcg(A,bRobin+b1*Temp2(0)+b2*Temp3(0),1e-3,100); uu(Me.UnknownNodes>0)= uT0; uu(lato2)=Temp2(0); %temperatura in t=0 uu(lato3)=Temp3(0); figure(4) Draw(Me,uu); title('Initial Solution');

%% Stationary Solution uTInf=pcg(A,bRobin+b1*Temp2(1e50)+b2*Temp3(1e50),1e-3,100); uu(Me.UnknownNodes>0)= uTInf; uu(lato2)=Temp2(1e50); %temperatura in t="Inf" uu(lato3)=Temp3(1e50); figure(5) Draw(Me,uu); title('Stationary solution');

%% Time Advancing figure(6);

u=uT0; dt1=1; dt2=10; dt3=100; dt4=500;

Page 41: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

40

tend=15000; t=0; while t<tend if t<tson t=t+dt1; [u,flag]=pcg((M+dt1/2*A), (M*u-

dt1/2*A*u+dt1/2*((bRobin+b1*Temp2(t)+b2*Temp3(t))+(bRobin+b1*Temp2(t-

dt1)+b2*Temp3(t-dt1)))),1e-6,200,[],[],u);%Crank-Nicholson

elseif t<tend/100 t=t+dt2; [u,flag]=pcg((M+dt2/2*A), (M*u-

dt2/2*A*u+dt2/2*((bRobin+b1*Temp2(t)+b2*Temp3(t))+(bRobin+b1*Temp2(t-

dt2)+b2*Temp3(t-dt2)))),1e-6,200,[],[],u);%Crank-Nicholson

elseif t<tend/20 t=t+dt3; [u,flag]=pcg((M+dt3/2*A), (M*u-

dt3/2*A*u+dt3/2*((bRobin+b1*Temp2(t)+b2*Temp3(t))+(bRobin+b1*Temp2(t-

dt3)+b2*Temp3(t-dt3)))),1e-6,200,[],[],u);%Crank-Nicholson else t=t+dt4; [u,flag]=pcg((M+dt4/2*A), (M*u-

dt4/2*A*u+dt4/2*((bRobin+b1*Temp2(t)+b2*Temp3(t))+(bRobin+b1*Temp2(t-

dt4)+b2*Temp3(t-dt4)))),1e-6,200,[],[],u);%Crank-Nicholson

end uutadv(Me.UnknownNodes>0)= u; uutadv(lato2)=Temp2(t); uutadv(lato3)=Temp3(t); hold off; Draw(Me,uutadv); zlim([0 100]); title(['t= ' num2str(t)]); drawnow; end title('Time Advancing');

figure(9) title('Difference between time advancing and stationary solution'); Draw(Me,uutadv-uu);

%% ODE 45

disp('End Time in ODE45 (choose low value, suggested<1000 s, otherwise wait

more XD)'); tend=input('Tend (s):');

figure(7);

u=pcg(A,bRobin+b1*Temp2(0)+b2*Temp3(0),1e-3,100); odepar=odeset('mass',M); [t,u]=ode45(@(t,y)(-

A*y+(bRobin+b1*Temp2(t)+b2*Temp3(t))),linspace(0,tend,10),u,odepar); uu=zeros(size(Me.Coordinates,1),1);

for k=1:length(t) uu(Me.UnknownNodes>0)= u(k,:); uu(lato2)=Temp2(t(k)); uu(lato3)=Temp3(t(k)); hold off;

Page 42: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

41

Draw(Me,uu); zlim([0 100]); title(['t= ' num2str(t(k))]); drawnow; end

figure(10) Draw(Me,uu-uutadv); title('Difference between time advancing and ODE45');

Auxiliary function: AssemblaDiffNOmRobin2 function [D,bRobin,b1,b2] = AssemblaDiffNOmRobin2(Me) %It assembles D Matrix and b vector of this particular problem in which %are involved non homogeneous Dirichlet, homogeneous Neumann and Robin %boundary conditions % %Input: % Me : Mesh % %Output: % D : Stiffness Matrix % bRobin : part of b vector due to Robin BCs % b1 : part of b vector due to Dirichlet BCs on Return Pipe % b2 : part of b vector due to Dirichlet BCs on Supply Pipe Tr=Me.Triangles; NI=Me.UnknownNodes; C=Me.Coordinates; N_Tr = size(Tr,1); N_int = max(NI);

D = spalloc(N_int,N_int,10*N_int); bRobin = zeros(N_int,1); b1 = zeros(N_int,1); b2 = zeros(N_int,1); % b3 = zeros(N_int,1); for e=1:N_Tr

Dx(1) = C(Tr(e,3),1) - C(Tr(e,2),1); Dx(2) = C(Tr(e,1),1) - C(Tr(e,3),1); Dx(3) = C(Tr(e,2),1) - C(Tr(e,1),1);

Dy(1) = C(Tr(e,2),2) - C(Tr(e,3),2); Dy(2) = C(Tr(e,3),2) - C(Tr(e,1),2); Dy(3) = C(Tr(e,1),2) - C(Tr(e,2),2);

Areass=Me.Aree(e); %valuto la forza xb=Me.CenterOfMass(e,1); yb=Me.CenterOfMass(e,2);

for i=1:3 ii = NI(Tr(e,i)); if( ii > 0) for j=1:3 jj = NI(Tr(e,j));

Page 43: Temperature Distribution in a ground section of a double-pipe system in a districti heating network

42

mu=get(Me.Shapes(Me.Faces(e)),'alfa',[xb,yb]); d=mu*(Dy(i)*Dy(j)+Dx(i)*Dx(j))/(4.0*Areass) ; if( jj > 0) D(ii,jj) = D(ii,jj) + d; else xy=C(Tr(e,j),:); aux=Me.DirichletNodes(-jj,:); val=Evaluate(Me.Bc, aux,xy); if Me.DirichletNodes(-jj,2)==2 b1(ii) = b1(ii) - d*val ; elseif Me.DirichletNodes(-jj,2)==3 b2(ii) = b2(ii) - d*val ; else % b3(ii) = b3(ii) - d*val ;

end

end end end end end

L=Me.Edges; Ro=Me.EdgesRobin;

for k=1:length(Ro) Nodo1=L(Ro(k),1); Nodo2=L(Ro(k),2); dist=norm(C(Nodo1,:)-C(Nodo2,:)); ii1=NI(Nodo1); ii2=NI(Nodo2); xmedia=(Me.Coordinates(Nodo1,1)+Me.Coordinates(Nodo2,1))/2; ymedia=(Me.Coordinates(Nodo1,2)+Me.Coordinates(Nodo2,2))/2; val=Evaluate(Me.Bc,Ro(k,:), [xmedia, ymedia]); h=val(1); g=val(2);

if ii1>0 && ii2<0 %ii1 è incognito, ii2 è noto bRobin(ii1)=bRobin(ii1)+g/2*dist; D(ii1,ii1)=D(ii1,ii1)+h*dist/3; elseif ii1<0 && ii2>0 %ii1 è noto, ii2 è incognito bRobin(ii2)=bRobin(ii2)+g/2*norm(dist); D(ii2,ii2)=D(ii2,ii2)+h*dist/3; else %allora sono entrambi di Neumann bRobin(ii1)=bRobin(ii1)+g/2*norm(dist); bRobin(ii2)=bRobin(ii2)+g/2*norm(dist); D(ii1,ii1)=D(ii1,ii1)+h*dist/3; D(ii2,ii2)=D(ii2,ii2)+h*dist/3; D(ii1,ii2)=D(ii1,ii2)+h*dist/6; D(ii2,ii1)=D(ii2,ii1)+h*dist/6; end end