M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

123
INVERSE ALGORITHM FOR DETERMINATION OF HEAT FLUX A Thesis Presented to The Faculty of the Fritz J. and Dolores H. Russ College of Engineering and Technology Ohio University In Partial Fulfillment of the Requirements for the Degree Master of Science BY Rong Zhong June, 2000 OHlO UblIVERSITY LIBRARY

description

M.S.Thesis Zhong_Inverse algorithm for determination of heat flux

Transcript of M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Page 1: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

INVERSE ALGORITHM FOR DETERMINATION OF HEAT FLUX

A Thesis Presented to

The Faculty of the

Fritz J. and Dolores H. Russ College of Engineering and Technology

Ohio University

In Partial Fulfillment

of the Requirements for the Degree

Master of Science

BY

Rong Zhong

June, 2000

OHlO UblIVERSITY LIBRARY

Page 2: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Acknowledgement

I wish to express my deep gratitude and sincere appreciation to my advisor, Dr.

Khairul Alam, Moss Professor, for his valuable guidance, encouragement and support

throughout this research.

I would like to thank Professor Hajrudin Pasic for his support and assistance in

this research and help with numerical methods. I wish to thank Dr. Lany Snyder,

Professor, Mathematics Department, for his help and suggestions.

My parents, brother and sister have also been a source of encouragement to me

throughout the time I have studied at Ohio University. Their encouragement has kept me

going during the times I felt overwhelmed.

Finally I would like to thank June and Warren Crockett, Lori and Mark Tyler,

Grace and Eddie Liu and all my hends for their encouragement and patience during this

time.

Page 3: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Table of Contents

...................................................................................................... Chapter 1 Introduction 1

1.1 The Inverse Problem .............................................................................................. 1

1.2 Objective of Current Research .............................................................................. 3

.................................................................................................... 1.3 Thesis Overview 3

.............................................................................. Chapter 2 Background and Relevance 5

........................................................................................................... 2.1 Introduction 5

.................................................................................................. 2.2 Literature Review 6

.............................................................................................. 2.3 Polynomial Solution 9

.................................................................................................................. 2.4 Theory 10

2.5 Solution for Polynomial q(t) .............................................................................. 12

........................................................................... 2.6 The Spline Interpolation Model 20

Chapter 3 Mathematical Model ...................................................................................... 21

......................................................................................................... 3.1 Introduction 21

3.2 Definition of the Problem .................................................................................... 21

3.3 Analytical Solution for the Direct Problem ......................................................... 23

3.4 Validation of Analytical Solution ........................................................................ 27

................................................................ 3.4.1 Checking the Governing Equation 27

3.4.2 Checking for the Boundary Conditions ......................................................... 29

3.4.3 Checking for the Initial Condition ................................................................ 30

Page 4: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

.................................................................. 3.5 Comparison with Alternate Solutions 3 1

...................................................................... 3.5.1 Validation for q(t) = constant 31

............................................................................. 3.5.2 Validation for q(t) = f (t) 32

................................................................................................... 3.6 Inverse Solution 32

............................................................................ 3.6.1 Cubic Spline Interpolation 36

.................................................. 3.6.2 Minimization Algorithm (IMSL Software) 36

........................................................................................ 3.6.3 Program Flowchart 40

...................................................................................... Chapter 4 Experimental Results 42

4.1 Quenching ............................................................................................................ 42

................................................................................................... 4.1.1 Introduction 42

............................................................................................... 4.1.2 Cooling Curve 43

........................................................................................... 4.2 Experimental Studies 44

................................................................................ 4.2.1 Experimental Apparatus 44

............................................................................... 4.2.2 Experimental Procedures 47

4.3 ExperimentalResults ........................................................................................... 48

............................................................................................................ Chapter 5 Results 51

......................................................................................................... 5.1 Introduction 51

5.2 Results from Polynomial Solution ....................................................................... 51

5.3 IHCP Algorithm with Cubic Spline ..................................................................... 57

.................................................................................... 5.4 Heat Transfer Coefficient 77

5.5 Effect of a Shortened Vapor Blanket Stage ......................................................... 78

Chapter 6 Discussion and Conclusions ........................................................................... 82

Page 5: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

6.1 Conclusion ........................................................................................................... 82

6.2 Future Work ......................................................................................................... 84

Reference .......................................................................................................................... 85

Appendix ........................................................................................................................... 89

Page 6: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

List of Tables

Table 3.1 Dimensionless Temperature Values, T' (x' , t' ) , for Various

Dimensionless Time and Distances for a

.................................................. Plate Heated at x = L and Insulated at x = 0 33

Table 3.2 Dimensionless Temperature Values, T' (x' , t ' ) , for Various

Dimensionless Time and Distances for a

.................................................. Plate Heated at x = L and Insulated at x = 0 34

Table 3.3 Comparison of Analytical and Finite Difference Solutions ............................. 35

Page 7: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

List of Figures

Figure 2.1 One-dimensional plate with boundary conditions .......................................... 1 1

Figure 3.1 Flowchart for IHCP ........................................................................................ 41

Figure 4.1 Quench probe .................................................................................................. 45

Figure 4.2 Picture of the quenching system showing the quench probe suspended

over a quench tank. ......................................................................................... 47

Figure 4.3 Cooling curve for 304 stainless steel for 10-degree quench angle test ....... ... 49

Figure 4.4 Cooling curve for 304 stainless steel for 60-degree quench angle test . . ... . .... 50

Figure 5.1 Comparison of experimental results with analytical profile obtained by

using a 6th degree polynomial approximation of the heat flux function

(quench angle = 10" ). . ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

Figure 5.2 Heat flux polynomial obtained by least-square matching of the analytical

and experimental temperature profiles (quench angle = 10"). ....................... 53

Figure 5.3 Comparison of experimental results with analytical profile obtained by

using a 6th degree polynomial approximation of the heat flux function

(quench angle = 60 " ). .... .... .. .. ...... .. . .. .. .... . ... . .. .... . . . . . . . . . . . . . . . . . . . ........ . . 54

Figure 5.4 Heat flux polynomial obtained by least-square matching of the analytical

and experimental temperature profiles (quench angle = 60" ). ....................... 55

Figure 5.5 Comparison of analytical and experimental temperature profiles using

a 8-interval cubic spline approximation for the heat flux function

Page 8: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

(quench angle = 10" , 2 time intervals in vapor blanket stage). ...................... 58

Figure 5.6 Heat flux profile obtained by using a 8-interval cubic spline

(quench angle = 10" , 2 time intervals in vapor blanket stage). ...................... 59

Figure 5.7 Heat transfer coefficient profile obtained by using a 8-interval cubic spline

(quench angle = 10" , 2 time intervals in vapor blanket stage). ...................... 60

Figure 5.8 Comparison of analytical and experimental temperature profiles using

a 15-interval cubic spline approximation for the heat flux function

(quench angle = 10" , 3 time intervals in vapor blanket stage). ...................... 61

Figure 5.9 Heat flux profile obtained by using a 15-interval cubic spline

(quench angle = 10" , 3 time intervals in vapor blanket stage). ...................... 62

Figure 5.10 Heat transfer coefficient profile obtained by using a 15-interval cubic

spline (quench angle = l o0 , 3 time intervals in vapor blanket stage). .......... 63

Figure 5.1 1 Comparison of analytical and experimental temperature profiles using

a 16-interval cubic spline approximation for the heat flux function

(quench angle = 10" , 4 time intervals in vapor blanket stage). ..................... 64

Figure 5.12 Heat flux profile obtained by using a 16-interval cubic spline

(quench angle = 10" , 4 time intervals in vapor blanket stage). ..................... 65

Figure 5.13 Heat transfer coefficient profile obtained by using a 16-interval cubic

spline (quench angle = 10" , 4 time intervals in vapor blanket stage). .......... 66

Figure 5.14 Comparison of analytical and experimental temperature profiles using

a 9-interval cubic spline approximation for the heat flux function

Page 9: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

(quench angle = 60" , 2 time intervals in vapor blanket stage) ...................... 68

Figure 5.15 Heat flux profile obtained by using a 9-interval cubic spline

(quench angle = 60" , 2 time intervals in vapor blanket stage) ...................... 69

Figure 5.16 Heat transfer coefficient profile obtained by using a 9-interval cubic

spline (quench angle = 60°, 2 time intervals in vapor blanket stage). .......... 70

Figure 5.17 Comparison of analytical and experimental temperature profiles using

a 13-interval cubic spline approximation for the heat flux function

(quench angle = 60" , 3 time intervals in vapor blanket stage) ...................... 71

Figure 5.18 Heat flux profile obtained by using a 13-interval cubic spline

(quench angle = 60" , 3 time intervals in vapor blanket stage). ..................... 72

Figure 5.19 Heat transfer coefficient profile obtained by using a 13-interval cubic

spline (quench angle = 60" , 3 time intervals in vapor blanket stage). ......... .73

Figure 5.20 Comparison of analytical and experimental temperature profiles using

a 14-interval cubic spline approximation for the heat flux function

(quench angle = 60" , 4 time intervals in vapor blanket stage) ...................... 74

Figure 5.21 Heat flux profile obtained by using a 14-interval cubic spline

(quench angle = 60" , 4 time intervals in vapor blanket stage) ...................... 75

Figure 5.22 Heat transfer coefficient profile obtained by using a 14-interval cubic

spline (quench angle = 60°, 4 time intervals in vapor blanket stage). .......... 76

Figure 5.23 Comparison of analytical and experimental results for 10-degree quench

angle test by cubic spline solution ................................................................. 79

Page 10: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Figure 5.24 Heat flux curve for 10-degree quench angle test by cubic spline solution .... 80

Figure 5.25 Heat transfer coefficient curve for 10-degree quench angle test by cubic

spline solution . . . ... . . . .. . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1

Page 11: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Chapter 1

Introduction

1 .I The Inverse Problem

Most heat conduction problems are concerned with the determination of

temperature distribution inside the solid body when certain initial and boundary

conditions are given, such as temperature or heat flux, which are known as a function of

time. These problems belong to the class of "direct problems." A direct problem has a

unique solution, because the solution involves a direct integration of differential

equations with known initial and boundary conditions. In practice, however, the surface

heat flux cannot be determined experimentally; but the temperature in the solid can be

monitored by sensors. In theory, a surface heat flux history can be calculated from a set

of temperature values, and this is called the "inverse heat conduction problem (IHCP)."

However, because of the errors that inevitably exist in the experimental data, the IHCP

often has non-unique solutions, leading to instabilities and convergence problems. The

inverse heat conduction problem is particularly difficult because it is extremely sensitive

to measurement errors (Beck, et al., 1985).

Inverse heat conduction problems arise because measurements can only be made

in easily accessible locations, or perhaps a desired variable can only be measured

indirectly. For example, we may want to estimate the temperature history on the inside

of a pressure vessel, but it is difficult to measure the temperature on the inside surface.

Page 12: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Therefore we use temperature profiles on the outside surface to estimate the temperature

and heat flux inside the vessel. In high-speed flight, such as spacecraft re-entry, shock

wave interaction with the spacecraft can produce enormous heat fluxes, which can

damage aerospace vehicles. To study these fluxes, the phenomenon is studied in

hypersonic wind tunnels. However, we cannot measure the flux in these situations.

Therefore, the temperature is measured and computations are done to recover the heat

flux.

We know that effective heat treatment and thermal processing of metals and

alloys is an essential component in the production of dependable components. More

exacting metallurgical specifications call for greater precision in heat treatment and

thermal processes. This has resulted in the need for accurate prediction and simulation of

these processes through experimentation and computer aided design. A critical case in

the simulation of quenching process is the determination of the surface heat transfer

coefficient, which is required as an input parameter. The accuracy of the simulation and

prediction is dependent on the surface heat transfer values.

Quenching experiments are often carried out to determine the surface heat fluxes

from experimental measurements of the temperature history. Therefore, this is a typical

IHCP, and the solution algorithms require special consideration. The goal of IHCP

algorithms for quenching is to determine the surface heat flux history from a set of

measured temperature histories inside a heat-conducting body. This is obviously an

estimation of the true values, since errors that are always present affect the accuracy of

the heat flux calculation.

Page 13: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

1.2 Objective of Current Research

The objective of this research is to estimate the surface heat flux of a one-

dimensional plate whose temperature history is obtained by a quenching experiment.

In this study we first develop an analytical solution to the direct problem, which consists

of determining the temperature in a one-dimensional plate for a given time-dependent

heat flux. The direct solution is determined by an approach based on the separation of

variables. To solve the inverse problem, we minimize the difference between the

experimental values and the analytical temperature calculated by assuming a surface heat

flux. The heat flux input at the surface is assumed to be a function q(t) whose values are

supposed to be known at a set of times t,, t, , . . . , tn. In our case, q(t) is approximated

as a cubic spline. A least square method is used to fit the analytical data to the

experimental solution and then evaluate the value of the heat flux q(t) , at the times t,,

t,, ... , tn. The heat flux history is the cubic spline fitted through these q(t) values.

Experimental data were obtained from experiments conducted at Ohio University by Zajc

(1 998).

1.3 Thesis Overview

Chapter 1 introduces the inverse heat conduction problem associated with

quenching. Chapter 2 gives the background of the IHCP problem. In chapter 3 a

mathematical description of the IHCP is displayed, the direct solution and inverse

solution of the problem are also shown. Chapter 4 explains the experimental setup,

Page 14: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

procedure, and the experimental results obtained at Ohio University. Chapter 5 discusses

the results of application of the IHCP algorithm. Chapter 6 presents a discussion of

results, the conclusions and suggestions for future work.

The above is a brief summary of the direct and inverse problems and the

importance of the inverse heat conduction problem. The next chapter provides a review

of the literature related to the IHCP problems.

Page 15: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Chapter 2

Background and Relevance

2.1 Introduction

The "direct problem", in which the governing differential equation with known

initial and boundary conditions is solved by integration, generally has unique solutions.

In the "inverse problem", the surface flux history is to be calculated from a set of

temperature values, and this should be possible in an ideal experiment. But the inverse

problem is extremely sensitive to any error in the input data. Because of the errors that

invariably exist in the experimental data, the IHCP often has non-unique solutions,

leading to instabilities and convergence problems.

Therefore, the inverse heat conduction problem is much more difficult to solve,

both analytically and numerically, than the direct problem. There are two main reasons

for the additional difficulty in solving the inverse problem. In the direct problem, the

high-frequency components of the applied heat flux are damped as the heat flow diffuses

through the solid medium. In the inverse problem, the opposite occurs. The high-

frequency components or noise in the measurements will be amplified in the projection to

the surface, and the resulting surface condition estimations can be easily overwhelmed by

the noise in the interior measurement.

The inverse problem is also made difficult by the factor that the physics of heat

conduction introduces a natural lag between the applied heat flux and the temperature

Page 16: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

response away from the flux. Thus, a step change in the surface heat flux will not be

fully felt in the interior until a finite amount of time has passed. There is a choice

between relatively difficult measurements or a difficult analytical problem. An accurate

and tractable inverse problem solution would thus minimize both disadvantages

simultaneously.

2.2 Literature Review

There have been many different approaches to the inverse heat conduction

problem. One of the earliest studies concerned with the calculation of heat transfer rates

during quenching of bodies of simple finite shapes was published by Stolz (1960).

Analytical solution techniques for IHCP were proposed by Burggraf (1964), Imber and

Khan (1972), Langford (1967), and Kover'yanov (1967). As we will discuss below, such

techniques have limited use for realistic problems, but they can give considerable insight

into the IHCP. Tikhonov (1977) introduced a regularization method to reduce those

sensitivities of ill-posed problems to measurement errors.

Stolz (1960) developed the analysis specifically for spheres and other simple

shapes. The system he chose was treated as a linear problem, permitting use of the

superposition principle. The essence of his method is the numerical inversion of a

suitable direct problem: given a surface heat flux versus time, find an interior temperature

versus time. He solved the problem in a sequential manner that did not change the basic

physical treatment of the problem. He did not consider the lag and damping of the

measurements, which result in the problem becoming ill-posed. Burggraf (1964)

Page 17: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

presented an approximate solution for unsteady conduction with unknown surface

boundary conditions. He approached the problem by assuming that both the temperature

T ( t ) and heat flux q(t) were known functions of time at a single sensor location inside

the medium. The temperature field was represented in terms of an infinite series of both

T ( t ) and q(t) and their derivatives and the solution was found for some very simple

geometry, such as a circular cylinder or a sphere. Kover'yanov (1967) developed results

for the hollow cylinders and spheres. Imber and Khan (1972) obtained an exact solution

for the temperature field using Laplace transforms when the temperature was known at

two distinct interior points. This method allows for the replacement of the input

thermocouple data by a temporal power series and a second series of error functions

weighted by powers of time. The resultant expression for the prediction temperature is in

the form of a summation of the repeated integrals of the error function. This method can

be used to determine boundary conditions at either face of a finite slab or hollow sphere.

Tikhonov regularization method and iterative regularization method are usually presented

as whole domain methods in which all the heat flux components are simultaneously

estimated for all times. Two advantages of these methods are that they have had rigorous

mathematical investigation and can be applied very generally.

Numerical methods have been the focus of recent studies in IHCP. Tervola

(1989) developed a numerical method to determine thermal conductivity from measured

temperature profiles. He defined the problem as an optimization problem where the heat

equation appears as a constraint. This optimization problem is solved with the Davidon-

Fletcher-Powell method, and in each iteration the heat equation is solved by finite

Page 18: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

element techniques with the predictor-corrector method. The boundary element method

(BEM) was used by Lesnic et al. (1998) to determine the boundary conditions in a

transient conduction problem where energies are specified in two areas of a one-

dimensional slab. Tseng et al. (1995), Hunag et al. (1995), and Keanini (1998) describe

applications of IHCP to manufacturing process. One-dimensional finite element

procedure was studied by Tseng et al. (1995) to predict the circumferential heat flux

during water-cooled hot rolling. Keanini (1998) developed a finite element solution of a

time-dependent, axially varying surface heat flux distribution during rolling.

Numerical solutions have an advantage over analytical solutions in that thermal

property variation is accounted for in the solution process. However, inverse calculations

based on numerical direct solutions tend to be computationally intensive and often have

convergence problems. The typical inverse algorithm uses an error minimization

approach, which is sensitive to the initial guess for the heat flux. The attraction of an

exact analytical solution is that it can provide a fast, approximate solution that can be

used as an intermediate step (or an initial guess) in a detailed and more accurate inverse

calculation. This would improve the efficiency of iterative numerical solutions, which

are highly sensitive to the initial guess.

The instability problem associated with IHCP has been discussed in detail by

Beck (1985). The instability arises from the fact that arbitrarily small differences in the

input data can produce arbitrarily large differences in the output values. A classic

problem in ICHP is the determination of surface heat flux in a one-dimensional slab. For

Page 19: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

the direct problem with a known constant heat flux, the temperature solution is known. If

the heat flux varies with time, Duhamel's theorem can be used to find a solution.

2.3 Polynomial Solution

Alam et al. (1999) describes an analytical solution to the direct problem, which

consists of finding the temperature in a one-dimensional plate for a given heat flux which

is assumed to be a polynomial function of time. The solution is based on separation of

variables, and is described in detail by Kumar (1998). To solve the inverse problem, a

least square method is used to minimize the difference between the analytical prediction

and experimental temperature profiles. The analytical approach is tested by using

experimental data that is obtained by quenching a special probe, which produces a good

approximation to the boundary conditions in the analytical solution. A least square

method is then used to produce best fit to the experimental data and determine the

polynomial coefficients of heat flux function.

The main idea is to assign heat flux as a k'th degree polynomial in time t ,

q ( t ) = a, + a,t + a2t2 + + aktk , where a,, a, , + . a , a, are unknown parameters. With this

information the heat transfer equation can be solved to yield a curve of temperature

versus time. By taking the experimental temperature at n times, t , , t , , . a , t , , we obtain

n equations for the determination of the k + 1 unknowns.

Quench probes have been used to collect temperature data in controlled

quenching experiments; the data is then used to deduce the heat transfer coefficients in

the quenching medium. The process of determination of the heat transfer coefficient at

Page 20: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

the surface is the inverse heat conduction problem, which is extremely sensitive to

measurement errors. This thesis reports on an experimental and theoretical study of

quenching that is carried out to determine the surface heat flux history during an

experimental quenching process by an inverse algorithm based on an analytical solution.

The algorithm is applied to experimental data from a quenching experiment carried out at

Ohio University. The surface heat flux is then calculated, and the theoretical curve

obtained from the analytical solution is compared with experimental results. The inverse

calculation appears to produce fast, but approximate results. These results can be used as

the initial guess to improve the efficiency of iterative numerical solutions, which are

sensitive to the initial guess.

2.4 Theory

Consider a one-dimensional heat conduction problem through a uniform plate, as

shown in Figure 2.1. At one end, x = 0 , the surface is insulated, and at x = L it is

subjected to heat flux q(L, t) , which is an unknown function of time. The governing heat

conduction equation describing the temperature distribution in the plate is

with the initial condition: T(x,O) = To (x) ,

Although the initial temperature is assumed to be uniform, the solution method

described below'will apply even when the initial temperature of the plate is a function of

Page 21: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

x . The boundary conditions correspond to the insulated left-end of the plate and the heat

flux input at the other end:

where:

a - Thermal difhsivity

k - Thermal conductivity

q - Heat flux

T - Temperature

x - Space coordinate

L - Thickness of plate

Figure 2.1 One-dimensional Plate with Boundary Conditions

Page 22: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

The IHCP problem to be solved may be stated as follows. Given a certain,

measured temperature T(0,t) profile as a function of time at x = 0 , find the heat flux

q(L,t) at x = L which produces the experimental temperature history. The solution will

also determine the temperature distribution as a function of space and time, i.e. T(x,t)

over the entire plate at any instant.

The analytical solution to the above problem for the special case of q = constant is

known to be the following (Beck et al., 1985):

2 9 [ [ ;))I cosnn: 1-- (2.5)

2.5 Solution for Polynomial q(t)

It is now necessary to determine the analytical solution for the case of time-

varying q(t). This is done by making the boundary conditions homogeneous by

introducing the following transformation:

Without loss of generality, it is assumed that the heat flux q(L, t) can be expressed

as a polynomial function of time:

Page 23: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

In the above equation am (m = 0,1,2, ... , j , ... ,p) are p + 1 undetermined

coefficients, which will be evaluated by minimizing the error between the experimental

and analytical solutions.

Differentiating equation (2.6) with respect to x, we get the following:

while differentiation of equation (2.6) with respect to t produces

Written in terms of y~ , the governing equation (2.1) now becomes

nonhomogeneous

The boundary conditions of this equation are now homogeneous:

at x=O; dT(x, t) = 0 , therefore, aw (x, t) = o

dx ax

a t x = L ; k W x , t) = q(L, t, am ) , therefore, aw (x, t) = o

dx ax

The initial condition at t = 0 changes to

Now one needs to solve equation (2.10) subjected to the boundary conditions in

equations (2.1 1) and (2.12), and the initial condition in equation (2.13). This was done

Page 24: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

nn by using the separation of variables method and using eigenvalues h = - and

L

eigenfunctions cos (nr) - of the homogeneous problem. We assume that the solution to

the nonhomogenous equation (2.10) is given by:

where Cn are coefficients that are to be determined. It should be noted that all these

coefficients ( C , ) are functions of time. Differentiating the above equation and

combining with equation (2.10) the following equation is obtained:

- - - q ( L y t y a m ) ((jx - 2 ~ ) +- 1 ( x 3 - L X ~ ) aq(L,t, a,) kL2 a k ~ '

> (2.15) at

where C, ( t ) is the time derivative of C, ( t ) . The coefficient C, ( t ) can be determined by

multiplying eqution (2.15) by the eigenfunctions and integrating over the domain.

For n = 0 this produces the following equation:

c, ( t ) = - q(Ly ty a , )a L dq(L, t , a,) +- kL 12k dt

Integrating equation (2.16) with respect to time we get:

Page 25: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

a a,tm+' co (t) = - C-- L + - q(L, t, a,) + const. kL ,=, rn + l 12k

From the initial condition it is seen that: Lao Co(0) =-+To 12k

For n greater than zero, we get the following set of equations:

12q(L,t,am' (cos(nn ) - 1) - k~n 'n

2L aq(L' " a m ) ((n 'n ' - 6)cos(nn ) + 6) h 4 n at

Integrating the above equation with respect to time, one obtains:

(cos(nn ) - 1)- kLn 2n '

- a (::; ;ldt] 2L aq(Ly ) ((n 'n ' - 6)cos(nn ) + 6)

at

where El, is a constant of integration.

P

The heat flux is assumed to have the form q(L,t,a,) = z a , t m . Therefore, m=O

equation (2.20) becomes

Page 26: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

where

2L 2 2 + --- ((n n - 6) cos(nn ) + 6 k?1471:

The two constants can be combined into one by taking En = E,, + E2, .

Therefore, equation (2.14) can be written as:

Page 27: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

I dq(L,t, a, -~ d2q(L, t, a , ) l2a (cos(nn - 1)) q(L, t, a,) +' kLn2n2

- dt2 3 c o s ( y )

n = l

Applying initial condition on equation (2.22) to determine En leads to the following

result for the analytical temperature profile:

" 2L - --- ((n 'n - 6) cos(nn ) + 6 n=l kn 4~

Page 28: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Having determined the temperature profile in terms of the heat flux, the final step

is the determination of the heat flux by using experimental data. This is the inverse

problem, and one now must find q(t), the polynomial hnction. This is now essentially

the problem of finding the unknown coefficients , a l , a m in the function

This is accomplished by applying the least-squares method to the temperature

profile from experiments, i.e.,

Page 29: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

where T is the analytically determined temperature profile given by equation (2.23),

while Te is the experimentally determined temperature. If 's' values of temperature data

are obtained from experiments, equation (2.24) requires that

2% (T - T, (ti))dr = 0 i=o 'am

for m=0,1,2 ,..., j ,..., p

Using the analytical solution for T(t) , it is possible to find the derivatives with

respect to the coefficients ao,a l ,..., a j ,..., a,. Let the derivatives be designated as rj(t) ,

'T(0, t) = rj (t) . j

This produces the following set of ' p ' equations from equation (2.26), with

Solving the above linear algebraic system in the coefficients by the Gauss

elimination method (or any other matrix inversion algorithm), one can find the

polynomial coefficients a,, a, ,..., a ,..., a, that are necessary for describing the heat flux

as a function of time. This is the heat flux sought that produces the given experimental

temperature profile at x = 0.

Page 30: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

2.6 The Spline Interpolation Model

To develop the analytical solution for the heat flux by the inverse algorithm

outlined above, the heat flux was assumed by Kumar (1998) to be a sixth-degree

polynomial fbnction of time, i.e.:

In the present study, we assign the heat flux to be a cubic spline function in time

t . The cubic spline is fitted to the experimental data such that the least square error

between the cubic spline and the experimental data is minimized. After the heat flux is

calculated in the cubic spline form, it is possible to compare the analytical value of the

temperature with the experimental data.

Page 31: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Chapter 3

Mathematical Model

3.1 Introduction

In chapter 2 we described an analytical solution based on a sixth-degree

polynomial. It will be shown later that a single polynomial cannot adequately match the

heat flux in typical quenching processes. We will now develop the inverse solution on

the basis of a cubic spline match to the experimental heat flux. We will first define the

mathematical problem, and then derive the analytical solution for the direct problem with

the boundary heat flux expressed as a cubic spline. The inverse problem consists of

calculating the analytical temperature history in the quenched part by using a cubic spline

form of the boundary heat flux and then comparing the analytical and the experimental

temperature profiles. The heat flux values at the node points of cubic spline are obtained

by minimizing the difference between the analytical and experimental temperature

profiles.

3.2 Definition of the Problem

The inverse problem is to estimate the surface heat flux function utilizing

measured interior temperature history. Our approach is to first develop a mathematical

Page 32: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

model and the solution of the direct problem. The direct problem was defined in chapter

2. We briefly summarize the direct problem below

Consider a one-dimensional heat conduction problem through a plate as shown in

Figure 2.1. It is assumed that the plate consists of a single material, homogeneous and

isotropic. At one end x = 0 , the bar is insulated, and at x = L it is subjected to a heat

flux q(t), which is an unknown function of time. The initial temperature of the plate

T(x,O) is assumed to be a known function of x .

For constant thermal properties, the governing heat conduction equation

describing the temperature distribution in the bar is:

subject to the initial condition, i.e.

The boundary conditions are given by the insulated left-end of the plate and the

heat flux input at the other end (Figure 2.1).

Page 33: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

3.3 Analytical Solution for the Direct Problem

Kumar (1998) used a sixth-degree polynomial for q ( t ) to solve the above

problem. In this study we will first assume a general form for q ( t ) , and finally use a

cubic spline to express q ( t ) .

As was done by Kumar (1998), the boundary condition is made homogeneous by

taking a transformation as following:

Now the governing equation (3 .1) becomes nonhomogeneous:

while the boundary conditions become homogeneous:

dT(x t) x = 0 ; ----1-- = 0 , therefore, h y ( x 7 t ) = 0

dx ax

x = L ; k t , = q( t ) , therefore, QJ ( x , t ) =O dx dx

The initial condition at t = 0 changes to:

q(0) (x3 - L x 2 ) = f ( x ) w (x,o) = T(x70) -

The homogeneous equation can be solved subject to the boundary conditions in

equations (3 .7) and (3 .8) , and the initial condition in equation (3 .9) by using the

separation of variables method. The homogeneous solution is given as:

Page 34: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

nn where hn = - are eigenvalues and cosh,x are eigenfunctions of the homogeneous

L

problem.

Now we assume that the solution to the nonhomogenous equation (3.6) is given

y (x, t ) = C en (t)e"';' cos hnx

Differentiating the above equation and combining with equation (3.6) the following

equation is obtained:

1 " 4( t ) 1 (x3 - L X ~ ) dq(t) - - C, (t)e-"':' cos hnx = - -- (6x - 2 ~ ) + - a .=o k ~ ~ a k ~ ~ dt

We multiply both sides cos h,x and integrate fiom 0 to L :

There are two different solutions depending on whether the integer n is zero or

non-zero.

Case 1: n = 0

a L d d t ) co ( t ) = - q(t) + - - kL 12k dt

Integrating equation (3.14) with respect to time we get:

Page 35: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Case 2: n > 0

12a (cos nn - 1 ) where A, =

kLn2n

Again integrating equation (3.16) with respect to time we get:

Finally, the general solution of equation (3.6) is:

( x , t ) = Co ( t ) + C, (t)e"r' cos h,x

Therefore the solution of the governing heat conduction equation subject to the

boundary condition is :

m 4 (0 C C, (t)e"^:' cos hnx + - ( x 3 - L X ' )

,=I kL2

where C , ( t ) is given by equation (3.17). Now we apply initial condition to equation

(3 .9) to determine Eo and E n .

Page 36: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

m d o ) Since T(x,O) = f (x) = z Cn (0) cos hnx + - (x3 - Lx2)

n=O k~~

Therefore,

m

z c n ( 0 ) c o s h n x = f (x) - m ( x 3 - Lx2) n=O kL2

We multiply both sides by cos hmx and integrate from 0 to L to find Eo and En :

After carrying out the integration and simplifying, the following expressions are

obtained for Eo and En :

l L E = [ f (x) - ( x 3 - Lx2) ni

0 I Case 2: n = 1,2,... :

Based on the above equations, the analytical temperature solution is given by:

12a(cosnn -1) ' + [ kLn2n2 14(7 )eagT ddr e"gt cos hnx

n=l 0 1

Page 37: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

m 2L + [- - [(n ' n - 6)cos nn + 61 1 n=l kn4n 0 dz

nn where An =-,n =1,2,..

L

3.4 Validation of Analytical Solution

3.4.1. Checking the Governing Equation

The above analytical solution to determine temperature profile can be checked by

back substitution into equation (3.12).

Since

Therefore:

Page 38: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Substitution into the equation (3.12) produces the following equation:

Equation (3.24) is valid if the following two equations are satisfied:

a " a - + A, cos h,x = -(6x - 2 1 ) kL .=I kL2

Equation (3.25) is satisfied if the left hand side is the Fourier cosine series

a a expansion of -(6x - 2L) with the first term - as the zeroth ( n = 0 ) term of the

kL2 kL

series. This is seen to be the case from the following orthogonality conditions:

For n=O weget: =- kL

For n = 1,2, , we get:

The above value of A, is the same as in equation (3.16); therefor equation (3.25) is a

valid solution.

Page 39: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

In a similar manner, equation (3.26) is satisfied if the left hand side is the Fourier

x3 - Lx2 L cosine series expansion of - with the first term - as the zeroth ( n = 0 ) term

k~~ 12k

of the series. This is seen to be the case from the following orthogonality conditions:

For n = 0 we get:

For n = 1,2, , we get:

The above value of B, is the same as in equation (3.16); therefor equation (3.26)

is valid.

3.4.2 Checking for the Boundary Conditions

From the analytical solution in equation (3. 23),

4(t) = 2 C, ( t ) h, e-"':' sin h,x + - (3x2 - 2Lx)

ax .=, kL2

nrr Since h, = - , therefore, sin h,x = 0 at x = 0, x = L . Consequently:

L

at x = O ; dT(x, t) = 0 ax

Page 40: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

3.4.3 Checking for the Initial Condition

Substituting t = 0 in equation (3.23) we get:

This can be written as:

From the above equation, we can see the first term on the right hand side is the

Fourier cosine series expansion of f (x). The term within the second parenthesis is the

4 (0) Fourier cosine expansion of - (x3 - Lx2), therefore it cancels the last term of the right kL2

side.

Consequently, at t = 0 ; T(x,O) = f (x) .

The above procedure proves that the analytical solution found is correct.

Page 41: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

3.5 Comparison with Alternate Solutions

3.5.1 Validation for q(t) = constant

A solution of the above quenching problem for the case of q( t ) = constant was

evaluated by Beck et al. (1985). For the coordinates of current problem this solution can

be written in non-dimensional form as follows:

T + at X Where T + = ---- , t =- x + = - - 4

L2 ' L . q = - . 9,L 1 k 4,

In order to compare our analytical solution with the above solution we first non-

dimensionalize equation (3.23) to obtain the following:

- f ( ~ + ) - q ( ~ ) ( ~ + ' - X + 2 )

12(cos nn - 1) " - +i[ n=l n2n2 n f q ( t ) e n z z d t 1e-nzn2t cos n m +

f (x' ) - i j ( ~ ) ( x + ~ - x * ~ ) e-n2n2t+ cos n m +

Page 42: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

To compare equations (3.27) and (3.28), the above was evaluated with

q(t) = constant = q, at x' = 1, andx' = 0 as the insulated surface. The temperature

values as a function of time are shown in Table 3.1. The solution calculated from

equation (3.27) as reported by Beck et al. (1985) is shown in Table 3.2 in the coordinates

of the current problem. Comparison of Table 3.1 and Table 3.2 shows that the two

solutions are in excellent agreement.

3.5.2 Validation for q(t) = f (t)

For the case of a variable heat flux given by q(t) = 10000t2 at x = L , and

T(x,O) = 400, we can obtain the temperature profile at x = 0 by using a finite difference

method. A finite difference program was written to compare numerical and analytical

solutions. Comparing the analytical profile with the results from finite difference method

(Table 3.3), it can be seen that the analytical solution (3.28) matches the finite difference

solution quite well.

3.6 Inverse Solution

The IHCP problem to be solved may be stated as follows. Given initial

temperature profile T(x,O) , and the measured temperature T(0, t) history as a function of

time at the position x = 0, find the heat flux q(t) at x = L which produces the

experimental temperature history. The solution will also determine the temperature

distribution as a function of space and time, i.e., T(x,t) over the entire plate at any

instant.

Page 43: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Table 3.1 : Dimensionless Temperature Values, T' (x' , t' ) , for Various Dimensionless

Time and Distances for a Plate Heated at x = L and Insulated at x = 0 .

(Source: Beck et al., 1985)

Page 44: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Table 3.2: Dimensionless Temperature Values, T' (x' , t' ) , for Various Dimensionless

Time and Distances for a Plate Heated at x = L and Insulated at x = 0.

Page 45: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Table 3.3 Comparison of Analytical and Finite Difference Solutions

In order to develop the analytical solution for the heat flux by the inverse

algorithm, the heat flux profile as a function of time was assumed to be a cubic spline. In

the last few sections we developed the analytical temperature solution as a function of the

heat flux. The next step is the determination of the heat flux by using experimental data.

This is the inverse problem, and we must find theq(t), which is a piecewise cubic spline

function. To find the heat flux, the difference between analytical temperature solution

and the experimental temperature is to be minimized. In our study, we use an

optimization routine from International Mathematics and Statistics Library (IMSL) to

find a best fitting cubic spline curve to match the experimental profile. The results will

t x = 0

400.0000 400.0000 400.0000 400.0109 400.0000 400.1246 400.3765 400.5320 401.9003 401.4413 403.4241 403.0617 406.4086 405.6022 410.23 14 409.2720 415.3688 414.2795 422.0577 420.8332 430.4652 429.1411

0.0

0.5

1 .o

2.0

2.5

3.0

3.5

4.0

4.5

5'0

Finite Difference Method Analytical Solution Finite Difference Method Analytical Solution FiniteDifferenceMethod Analytical Solution Finite Difference Method Analytical Solution Finite Difference Method Analytical Solution Finite Difference Method Analytical Solution Finite Difference Method Analytical Solution Finite Difference Method Analytical Solution Finite Difference Method Analytical Solution Finite Difference Method Analytical Solution Finite Difference Method Analytical Solution

x = 0.25

400.0000 400.0000 400.0000 400.0121 400.0000 400.1446 400.4627 400.5927 401.9865 401.5632 403.6609 403.2637 406.6676 405.9020 410.6609 409.686 415.9697 414.8240 422.8306 421.5243 431.4326 429.9954

x = 0.5L

400.0000 400.0000 400.0000 400.0208 400.0027 400.2188 400.7213 400.8022 402.2650 401.9795 404.4127 403.9588 407.6538 406.9485 412.0363 41 1.1569 417.8438 416.7921 425.2805 424.0625 434.5639 433.1763

x = 0.75

400.0000 400.0000 400.0000 400.0498 400.1196 400.3803 401.1524 401.2126 402.9855 402.7569 405.6795 405.2221 409.4989 408.8172 416.6008 413.7509 421.2423 420.23 18 429.6306 428.4681 439.9739 438.6680

x = L

400.0000 400.0000 400.0253 400.1 173 400.4086 400.6732 401.7902 401.8936 404.2209 403.9875 407.5948 407.1621 412.2865 411.6249 41 8.4412 417.5838 426.3033 425.2470 436.0784 434.8229 447.9499 446.5198

Page 46: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

be an approximation to the heat flux profile in the form of a cubic spline. This is

described in the following sections.

3.6.1 Cubic Spline Interpolation

We sometimes know the value of a function f (x) at a set of points x, , x, , a , x, ,

but we don't have an analytical expression for f (x) that lets us calculate its value at an

arbitrary point. We want to estimate f (x) for arbitrary x by drawing a "smooth curve"

through data points xi. Mathematically, it is possible to construct cubic functions S, (x)

on each interval [x,, x,,,] so that the resulting piecewise curve y = S(x) and its first and

second derivatives are all continuous on the large interval [x,, x,]. In this study we use a

natural cubic spline for which the second derivative of the interpolating curve vanishes at

the first and the last data points of the original set.

In the computer program, which is included in the appendix, there are two

subroutines (SPLINE, SPLINT), which allow the user to interpolate a value given a set of

data points yi = f (xi) . These subroutines require the value yi at the point xi . During

the minimization process, the value of y, are obtained so that the cubic spline based on

yi = f (xi ) represents the heat flux which produces minimum error between the

analytical and experimental temperatures.

3.6.2 Minimization Algorithm (IMSL Software)

The IMSL software that was used in this calculation is a library of C language

subroutines useful in scientific programming. Each fbnction is designed and documented

to be used in general programming tasks.

Page 47: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

In this study a number of routines from this library were used. One is called

"bounded - least-squares", which can solve a nonlinear least-squares problem subject to

simple bounds on the variables using a modified Levenberg-Marquardt algorithm.

The following synopsis provides directions for using this routine:

Synopsis:

#include <imsl.h>

float *imsl~f~bounded~least~squares(void fcn(), int m, int n, int ibtype, float xlb[], float

xub[], . . . , 0)

Required Arguments:

void fcn (int m, int n, float x[], float fl]) (InputIOutput)

This is a user-supplied hnction to evaluate the function that defines the least-

squares problem where x is a vector of length n at which point the fhnction is

evaluated, and f is a vector of length m containing the function values at point x.

int m (Input)

Number of functions (number of experimental data points).

int n (Input)

Number of variables (number of cubic spline points), where n I m.

int ibtype (Input)

Scalar indicating the type of bounds on the variables.

float xlb[] (Input, Output, or Input/Output)

Array with n components containing the lower bounds on the variables.

Page 48: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

If there is no lower bound on a variable, then the corresponding xlb value should

be set to -lo6.

float xub[] (Input, Output, or InputIOutput)

Array with n components containing the upper bounds on the variables.

If there is no lower bound on a variable, then the corresponding xub value should

be set to lo6.

Return Value:

A pointer to the solution x of the nonlinear least-squares problem. To release this space,

use free. If no solution can be computed, then NULL is returned.

Synopsis with Optional Arguments:

#include <imsl.h>

float *imsl~f~bounded~least~squares (void fcn(), int my int n, int ibtype,float xlb[],

float xub [I,

IMSL-XGUESS,float xguess[],

IMSL-JACOBIAN, void jacobiano,

IMSL-SCALE,float xscale[],

. . .,

0)

x[] in this function represents the heat flux values at n data points, fi] is the

difference between the experimental temperature and the analytical temperature at every

iteration. The total number of experimental data points used in this calculation is 120

(m=120). The number of cubic spline intervals are 9, 15, 16 and 23 (n=10, 16, 17,24).

Page 49: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

The analytical solution requires integration of certain functions. This is done by

using a number of routines. A typical subroutine is the "int-fcn". This routine integrates

a function by using a globally adaptive scheme based on Gauss-Kronrod rules. It

subdivides the interval [a, b] and uses a (2k + l)-points in each subinterval.

The following is the synopsis of this routine as given in IMSL manual:

Synopsis:

float imsl-f-int-fcn (float fcn(), float a,float b, . . . , 0)

Required Arguments:

float fcn (float x) (Input)

User-supplied function to be integrated.

float a (Input)

Lower limit of integration.

float b (Input)

Upper limit of integration.

Return Value:

b

The value of fcn(x)dx is returned. If no value can be computed, then NaN is returned. a

Synopsis with optional Arguments:

float imsl-f-int-fcn (float fcn(float x),float a,float b,

IMSL-RULE, int rule,

Page 50: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

IMSL - ERR - ABS,float err-abs,

IMSL-ERR-REL, float err-rel,

. . .,

0)

3.6.3 Program Flowchart

The flowchart for IHCP solution is given in Figure 3.1. The primary inputs are

experimental temperature data points, the cubic spline intervals, and material properties.

The upper bound was made approximately 0, and no limit was set for the lower bound.

Page 51: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Start 1 Input

Experimental time Experimental temperature

Initialize 1 .Parameters of one-dimensional problem 2.Heat flux cubic spline function 3 .The calculation tolerance 4.Special parameters of routines 5 .The upper and lower bounds for solution

Calculate The analytical temperature profile

Minimize The difference between the experimental Data and the analytical solution

No

Output 1 .The analytical temperature 2.Heat flux solution 3 .Heat transfer coefficient

Stop

Figure 3.1 Flowchart for IHCP

Page 52: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Chapter 4

Experimental Results

In this chapter the quenching process will be briefly described, along with the

experimental setup which is used to determine the temperature history during quenching.

These experiments were carried out in research studies (Zajc, 1998; Kumar, 1998) at the

Department of Mechanical Engineering at Ohio University.

4.1 Quenching

4.1.1 Introduction

Many metal alloys that are currently being manufactured are subjected to heat

treatment before being placed in service. They are heat treated in order to improve

certain properties, such as hardness, strength, toughness, ductility and corrosion

resistance, as well as to increase uniformity of the properties. Quenching is a particular

type of thermal treatment process that involves rapid cooling of metal alloys for the

purpose of hardening.

Alloys of iron are quenched to prevent the austenite from decomposing under

equilibrium conditions thereby producing microstructures that alter the mechanical

properties of the materials. The word quenching, when applied to the heat treatment of

steel, covers the process of cooling the steel from the austenitizing temperature at a rate

Page 53: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

such that decomposition of the austenite will occur at sub-critical temperatures. The

quenching medium can be a gas, liquid, or solid. The quenching problem is one of heat

transfer. The quenching medium extracts heat from the surface of the steel which results

in steep temperature gradients being set up in the body of the steel.

4.1.2 Cooling Curve

Among the various experimental results that have been used to predict the ability

of quenching process to get the desirable properties, the cooling curve is the most

popular. Cooling curves are obtained experimentally using an apparatus that primarily

consists of an instrumented quench probe to monitor the interior temperature response

and a data acquisition system to collect and display the sampled data.

If a heat-treated steel part is continuously cooled from a solution treating

temperature in a quenching medium that rapidly extracts heat, four stages of heat transfer

will take place. These stages characterize the four different cooling mechanisms that

occur during quenching. The four cooling stages are: (i) the initial liquid contact or

wetting stage, (ii) the vapor blanket or film boiling stage, (iii) the nucleate boiling stage,

and, (iv) the convective heat transfer stage. Except the first stage, other three stages are

recognizable on cooling curve obtained by experimental procedures. The first stage lasts

for an extremely short time, and is generally not detected in the experimental cooling

curve.

Page 54: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

4.2 Experimental Studies

4.2.1 Experimental Apparatus

In the quenching experiment the following equipment was used: quench probe,

quenching probe support, quench tank, data acquisition hardware, data acquisition

software and computer. This is briefly described below:

Quench Probe:

Experiments were conducted with a stainless steel probe in the shape of a

rectangular box, which is shown in the Figure 4.1. This probe is a rectangular box

approximately 15cm-by-10 cm-by-2.5 cm. Each wall of this probe box is 6 mm thick

(Zajc, 1998). The cover of the probe box was screwed on with a gasket to make it

watertight and the inside surface of the largest side was instrumented with type K

thermocouples. Since the box is empty inside, the inside surfaces can be assumed to be

insulated (convection heat transfer to the air from the walls is negligible for the short

duration of the quench test). This probe is assembled with the thermocouples that pass

through the handle of the probe, and then the probe box is sealed with the cover. The

probe was heated to a specified steady-state temperature (typically 400°C), and then

quenched in water in a quenching tank.

Quenching Probe Support:

The quench probe is supported by a metal fixture that can lower the probe into the

water at different angles. The angle that the probe is quenched is determined by the

seven sets of mounting holes in the adjustment plate that are spaced in 10 degree

Page 55: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

(b)

Figure 4.1 Quench Probe: (a) Schematic of the box shaped probe showing the

walls and the screw holes for attaching the top, (b) Picture of the probe used in the

experiments -the cover has been removed to show the thermocouples connected to the

inside of the probe wall

Page 56: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

increments, therefore, the probe could be potentially quenched at any 10 degree interval

between 0 and 60 degrees.

Quenchant and Quench Tank:

The quenchant used during the experiments was water. The water was held in a

100 gallon quenching tank shown in Figure 4.2 that is made of a high strength plastic. A

plastic tank is used to ensure that a reaction does not occur between the quenchant and

the tank that could potentially change the composition of the quenching medium.

Data Acquisition Hardware:

The data acquisition equipment consists of the following:

(i) D.A.S. 1701 board made by Keithley Metrabyte. This board has 16 single-

ended or 8 differential channels with 12-bit resolution, 166.67 x 1 o3 samples/second

maximum throughput, and gains of 1, 5,50 and 250.

(ii) The software package used to collect the data for analysis during the

experiments is called TestPoint. Each of the thermocouples was sampled every 0.01

second for approximately 1 to 2 minutes. TestPoint has several capabilities which

include: controlling external measurement devices, creating user interface item,

displaying and analyzing data, creating files, and dynamically exchanging data with other

software applications. Furthermore, TsetPoint applications have the ability to support

sequential execution, repeating loops, and conditional statement.

(iii) Computer: P5-200 Gateway 200 MHz Pentium processor, 32MB SDRAM,

3.0 GB hard drive.

Page 57: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Figure 4.2 Picture of the quenching system showing the quench probe suspended over a quench tank.

4.2.2 Experimental Procedures

The experimental procedures consisted of three steps:

Step 1 : Heat the probe up to the specified steady-state temperature.

Step 2: Initialize the data acquisition system and remove the probe fi-om the

furnace.

Step 3: Lower the probe into the tank to quench the probe and collect the data for

approximately 2 minutes.

Page 58: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

4.3 Experimental Results

The experimental results of temperature versus time are given in Figure 4.3 and

Figure 4.4 for quenching experiments carried out at 10 degree and 60 degree angles. In

each figure the two curves correspond to the data from two thermocouples which are

attached to the inside surface (at the center and at the comer) of the 15cm-by-l0cm wall

of the probe. Since the wall thickness (6mm) is much smaller than the wall dimensions,

the one-dimensional solution is valid for this wall of the probe. This is verified by the

close matching of the two temperature profiles. It can be observed that the thermocouple

data indicate a rapid cooling period of about 10 seconds after approximately 2 seconds of

quenching. This is characteristic of quenching curves (Totten et al., 1994).

The first part of the curves are nearly horizontal; this period corresponds to the air

cooling of the probe during transport from the oven to the quenching system, and the

vapor blanket stage at the beginning of quenching. The rapid cooling part of the curves

represents the nucleate boiling stage. The final part of the cooling curves is the

convective cooling stage.

The goal of the inverse heat transfer algorithm is to estimate the heat flux from

the probe on the basis of this cooling curve. This is done in the following chapter.

Page 59: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux
Page 60: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux
Page 61: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Chapter 5

Results

5.1 Introduction

In this chapter we present the results from the application of the IHCP algorithm

with the cubic spline approximation of the heat flux history for the quenching process.

The heat flux curves, heat transfer coefficient plots and the comparison of the analytical

and experimental temperature curves will be presented.

5.2 Results from Polynomial Solution

Figures 5.1 to 5.4 show the results obtained by using an IHCP code from a

previous study (Alam et al., 1999). In this method the temperature solution is obtained

by using a 6th degree polynomial to estimate the heat flux during quenching of the probe.

The analytical temperature history is obtained by carrying out a least-square error

minimization of the experimental and analytical temperature history obtained from the 6th

degree heat flux polynomial. The experimental data consists of 12,000 temperature data

points over 120 seconds of quenching time. The average of every 100 points is computed

in order to get a smooth curve containing 120 points, with adjacent points separated by 1

second.

Page 62: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux
Page 63: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux
Page 64: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux
Page 65: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux
Page 66: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

It is seen that the temperature profiles compare reasonably well for the 10-degree

and 60-degree quenching angles, but the analytical temperature profiles have a 'wavy'

shape which is not representative of the continuous cooling of the probe. The

temperature profile shows an increasing trend at several points in the analytical curve, for

example after 40 seconds of cooling. This could be due to the fact that a single 6th degree

polynomial is being used. This produces the heat flux curves as shown in Figures 5.2 and

5.4.

The heat flux curves demonstrate another problem in that the heat flux curves are

very unrealistic after the first 60 seconds. In one case the heat flux shows a very high

negative value, and in the other we see a very high positive value (the positive heat flux is

obviously impossible for this process). This error is due to the fact that there is a

significant diffusion time lag between the quenching surface at x = L , and the

thermocouple position at x = 0 . This time lag has a characteristic time of L~ / a , and is

of the order of 10 seconds. Consequently, the analytical temperature prediction during

the last 10 to 30 seconds is quite insensitive to the heat flux prediction. The polynomial

that results from this error minimization algorithm is not influenced by the heat flux

curve for the final part of the quenching. These results in the mismatch observed in the

heat flux curves. Therefore, to match the data set for 120 seconds with a polynomial

form of the heat flux curve, additional data points should be included beyond the 120

seconds (either from experiment, or by simple extension of the experimental temperature

history).

Page 67: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

It can also be seen from the figure that a continuous polynomial profile for heat

flux may not be very accurate when the temperature slope has a sudden change, such as

near the end of the vapor blanket stage.

5.3 IHCP Algorithm with Cubic Spline

In order that the errors caused by the use of a single polynomial can be avoided;

we have expressed heat flux by a cubic spline, which is made up of a set of cubic

polynomials defined over a set of time intervals. Therefore, our results depend on the

number of intervals, and the width of the intervals used in the error minimization

algorithm. In the calculations carried out to determine the heat flux, the number of

intervals for the different stages of cooling was taken as a variable parameter. It was

observed that the oscillations tend to occur near the end of the vapor blanket stage. This

is due to the fact that there is a sharp drop in the temperature right after the vapor blanker

stage. In the results described below, the total number of spline intervals were varied

from about 8 to 16; with 2 to 4 intervals in the vapor blanket stage.

The results of the comparison of the experimental data with analytical solution

based on different time intervals for the cubic spline are shown in the following pages.

Figures 5.5 to 5.13 show the comparison of analytical and experimental temperature

profiles for 10 degree quench angle, the heat flux curve predicted by the IHCP algorithm,

and the heat transfer coefficient obtained by the analysis. It can be seen that the vapor

blanket stage lasts for about 15 to 20 seconds, and is followed by the nucleate boiling

Page 68: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux
Page 69: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

b b b O b b b b * * * 0 0 0 0 0 0 0 0 0 0 0

W W W W W W W W W W W 9 - 8 z 9 9 9 9 9 9 ? 3 ? % ' * ?

(,WIM) xnld Jew

Page 70: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux
Page 71: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux
Page 72: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

8 8 8 8 8 8 8 8 8 8 8 8 + + + + + + + + + + + + W W W W W W W W W W W W

2 zzz?;q; 9 9 : ; ;

Page 73: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux
Page 74: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux
Page 75: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

s g g g g g g $ b b b 0 0 0 + + + + + + + +

W W W W W W W W W W W $ 8 $ 9 9 9 9 9 9 ; ? I - ? ' ' ? * ?

Page 76: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux
Page 77: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

stage with high heat flux for about 10 seconds. The convective heat transfer stage sets in

after approximately 30 seconds. In these figures, it can be observed that the analytical

and experimental temperature profiles match reasonably well when sufficient number of

intervals are used. The differences due to the number of intervals show up in the heat flux

curves (and therefore in the heat transfer coefficient). As will be shown later, the results

are very similar for 60 degree quench angle.

The heat flux in the nucleate boiling stage is seen to have a maximum value of

about 70 kw/m2 for 10 degree quench angle. The heat flux is not very accurate when

only 8 intervals are used (Figure 5.5 -5.7); the temperature profile tends to be wavy and

the maximum heat flux is 58 kw/m2. This is not surprising, since the inverse problem is

very sensitive to input parameters. A similar variation is seen for the 60 degree quench

angle (Figures 5.14 to 5.22). However, the 60 degree quench angle test appears to have a

higher maximum flux (approximately 110 kw/m2).

Therefore, it is quite critical that the number of time intervals be varied in order

that the heat flux can be calculated with a good degree of confidence. Even though the

optimization was carried out with the constraint of heat flux constrained to be negative in

the IMSL code, it is seen that the code results contain positive heat fluxes which are

typically 20 kw/m2 (about 20% of the maximum value). This error in the IMSL solution

could not be resolved.

In all curves, the final stages of the cooling show the expected decay towards zero

heat flux. This is in sharp contrast to the single polynomial case discussed earlier.

Page 78: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Tim

e (s

econ

d)

Figu

re 5

.14

Com

pari

son

of a

naly

tical

and

exp

erim

enta

l tem

pera

ture

pro

file

s us

ing

a 9-

inte

rval

cub

ic s

plin

e

appr

oxim

atio

n fo

r the

hea

t fl

ux f

unct

ion

(que

nch

angl

e =

60°

, 2 ti

me

inte

rval

s in

vap

or b

lank

et s

tage

).

Page 79: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux
Page 80: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux
Page 81: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux
Page 82: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux
Page 83: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux
Page 84: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Figu

re 5

.20

Com

pari

son

of a

naly

tical

and

exp

erim

enta

l tem

pera

ture

pro

file

s us

ing

a 14

-int

erva

l cub

ic s

plin

e

appr

oxim

atio

n fo

r the

hea

t flu

x fu

nctio

n (q

uenc

h an

gle

= 6

0°,

4 ti

me

inte

rval

s in

vap

or b

lank

et s

tage

).

Page 85: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux
Page 86: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Tim

e (s

econ

d)

Figu

re 5

.22

Hea

t tra

nsfe

r coe

ffic

ient

pro

file

obt

aine

d by

usi

ng a

14-

inte

rval

cubi

c sp

line

(que

nch

angl

e =

60

°, 4

tim

e in

terv

als

in v

apor

bla

nket

sta

ge).

Page 87: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Therefore, the piecewise continuous cubic spline is not affected strongly by the diffusion

time lag as was seen with the single polynomial.

Since the vapor blanket stage ends in a sharp drop into the nucleate boiling stage,

the (Figures 5.5, 5.14), the temperature in vapor blanket stage is not matched very well.

The cubic spline tends to produce fluctuations in and near the vapor blanket stage. This

is strongly influenced by the number of intervals used in the vapor blanket stage. When

the number of intervals in the vapor blanket stage is increased (Figures 5.8 to 5.13, and

5.17 to 5.22), the temperature profiles show an improvement in the match with the

experimental curve. However, the temperature profile in vapor blanket stage now has a

sinusoidal variation, and that produces a sinusoidal variation in the vapor blanket stage of

the heat flux curves.

5.4 Heat Transfer Coefficient

According to the convection heat transfer equation, the heat transfer coefficient is

given by:

From the analytical solution of the IHCP algorithm, we can get the heat transfer

coefficient curves for each of the cases by using the heat flux curve ( q ) for the

numerator, and the temperature solution (T ) values in the denominator.

The heat flux values will obviously reflect the fluctuations observed in the heat

flux curves, and this can be observed in the heat transfer coefficient curves shown in

Page 88: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Figures.5.7, 5.10, 5.13, 5.16, 5.19, and 5.22. The heat transfer coefficients show large

fluctuations when the heat flux curve oscillates. As the number of time intervals is

increased, the heat transfer coefficient curves attain more stable values. Therefore,

increasing the number of time intervals reduces the fluctuations in the heat flux and heat

transfer coefficients.

It appears that the problems in the IHCP algorithm originate from the sharp

changes in the temperature and heat flux profiles. In order to examine this aspect, the

following simulation was carried out.

5.5 Effect of a Shortened Vapor Blanket Stage

To examine the effect of the vapor blanket stage curve, simulations were carried

out after reducing the experimental data set so that only 3 seconds of the vapor blanket

stage remained. The results are shown in Figures 5.23 to 5.25. The temperature profiles

match very well. The heat transfer coefficient profile is not very smooth (23 intervals

were used), but the values are reasonable. There is an improvement in the heat flux curve

in that the heat flux history shows a consistent decrease after the first 3 seconds, and

fluctuations are minimal.

Page 89: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux
Page 90: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux
Page 91: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux
Page 92: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Chapter 6

Discussion and Conclusions

6.1 Conclusion

An inverse heat transfer algorithm was developed to find the surface heat flux in a

quenching process. The algorithm uses an analytical solution to calculate the surface heat

flux as a cubic spline containing a variable number of intervals, each of which is spanned

by a cubic polynomial. The algorithm was then tested with experimental data.

The experimental data consisted of 12,000 data points for 120 seconds of

quenching. This data was used to determine the surface heat flux history. It was shown

that a single polynomial provides reasonably accurate results for simple quenching

histories, but is not able to match temperature jumps very accurately.

A piecewise continuous polynomial, such as a cubic spline, can represent any

arbitrary heat flux quite accurately. Therefore a cubic spline was selected for the IHCP

algorithm. It was observed that the cubic spline produces better match to the temperature

history, and more accurate heat fluxes over a wider time span. However, even the cubic

spline produces temperature and heat flux fluctuations that are not physically realistic.

Increasing the number of time intervals can reduce these fluctuations. However, the

basic problem is the acute sensitivity of the heat flux to the input data. The IHCP

Page 93: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

problem tends to be highly unstable; consequently more stable methods have to be

developed to reduce the fluctuations in the inverse solution.

It may be possible that using piecewise continuous straight lines instead of cubic

polynomials can improve the stability of the solution. When the heat flux curve is

assumed to be a cubic spline, the curve is forced to be smooth because of the requirement

that the first derivative is continuous at the interface between the intervals. This

requirement tends to produce variations in the heat flux curve that are similar to

sinusoidal curves. A curve made of piecewise continuous straight lines may produce a

more stable, although not a highly accurate solution.

It is also quite likely that the cubic polynomial estimation for the heat flux leads

to a large number of degrees of freedom in the solution, because of which the solution

curve may not converge to the shape that is physically more plausible. To improve the

solution, more constraints may be needed. A constraint that could be applied is that the

heat flux curve must have a negative or zero slopes at all times. This constraint was not

applied in the IMSL code because the results from the code did not satisfy the first

constraint that the heat flux be negative. The IMSL code did not produce satisfactory

results; but this is not surprising. It should be noted that constrained optimization is a

difficult problem, and global minimum is often not achieved.

The primary advantage of this algorithm is that it appears to produce very fast

results as compared to other solution schemes. This algorithm, if improved further, can

be used as the initial guess to the numerical solution methods used in multi-dimensional

solutions. It should be noted that multi-dimensional inverse problems sometimes do not

Page 94: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

converge, or require hours of computational time because the solution steps are very

sensitive to the input data, which includes the initial guess. A good initial guess in a

complex multi-dimensional problem can reduce the solution time considerably.

6.2 Future Work

Since this method is applicable to many functional representations of heat flux,

future work should focus on using the inverse algorithm with a piecewise continuous

polynomial of different degrees, including the straight line representation. Future work

could also be extended to two- and three-dimensional analytical models and their

experimental verifications. These models can then be integrated with finite element and

finite difference inverse codes.

The selection of a proper minimization/optimization code should also be

investigated. The IMSL optimization routine used for this study did not perform

satisfactorily. A more flexible routine that will allow more constraints may perform

better for the IHCP problem.

Page 95: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Reference

Alam, M. K., Pasic, H., Anugarthi, K., Zhong, Rong, 1999, "Determination of Surface

Heat Flux in Quenching", to be published in ASME IMECE proceedings, Nashville,

November, 1999.

Beck, J. V., Ben Blackwell, and Charles R. St. Clair, Jr., 1985, Inverse Heat Conduction,

I11 Posed Problems, A Wiley-Interscience Publication, New York.

Beck, J., V. B. Blackwell and A. Haji-Sheikh, 1996, "Comparison of some inverse heat

condition methods using experimental data", Int. J. heat Mass transfer, Vol. 39, No. 17,

pp. 3649-3657.

David, M. Trujillo and Henry, R. Busby, Practical Inverse Analysis in Engineering, CRC

Press, Boca Raton, New York, 1997.

Huang, C. H., Ju, T. M., and Tseng, A. A., 1995, "The estimation of surface thermal

behavior of the working roll in hot rolling process", Int. J. Heat Mass Transfer, Vol. 38,

pp. 1019-1031.

Page 96: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Imber, M. and Khan, J., 1972, "Prediction of transient temperature distributions with

embedded thermocouples", AIAAJ, Vol. 10, pp. 784-789.

IMSL CIMathlLibrary, 1995, "C hnctions for mathematical applications", Visual

Numerics, Houston, Taxas.

Keanini, R. G., 1998, "Inverse estimation of surface heat flux distributions during high

speed rolling using remote thermal measurements", Int. J. Heat Mass Transfer, Vol. 41,

pp. 275-285.

Kover'yanov, V. A., 1967, "Inverse problem of nonsteady-state thermal conductivity",

Teplofizika Vysokikh Temperature, Vol. 5(1), pp. 141-143.

Kumar, 1998, "Analytical Solution for Inverse Heat Conduction Problem", M.S. Thesis,

Ohio University.

Langford, D., 1967, "New analytic solutions of the one-dimensional heat equation for

temperature and heat flow rate both prescribed at the same fixed boundary (with

applications to the phase change problem)", Q. Appl. Math, Vol. 24, pp. 315-322.

Page 97: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Lesnic, D., Elliott, L. and Ingharn, D. B., 1998, "The solution of an inverse heat

conduction problem subject to the specification of energies", Int. J. Heat Mass Transfer,

Vol. 41, pp. 25-32.

Burggraf, 0 . R., 1964, "An Exact Solution of the Inverse Problem in Heat Condition

Theory and Application", Journal of Heat Transfer, pp. 373-380.

Press, William H., Teukolsky, Saul A., Vetterling. William T. and Flannery, Brian P.,

1992, Numerical Recipes in C: the Art of Scientific Computing, Cambridge University

Press.

Stolz, G., Jr., 1960, "Numerical solutions to an inverse problem of heat conduction for

simple shapes", J. Heat Transfer, Vol. 82, pp. 20-26.

Tervola, P., 1989, "A method to determine the thermal conductivity from measured

temperature profiles", Int. J. Heat Mass Transfer, Vol. 32, pp. 1425-1430.

Tikhonov, A. N. and Arsenin, V. Y., 1997, Solutions of Ill-Posed Problems, V. H.

Winston & Sons, Washington, D.C..

Totten, G. E., Bates, C. E. and Clinton, N. A., 1994, Handbook of Quenchants and

Quenching Technology, Materials Park, Ohio: ASM International.

Page 98: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Tseng, A. A., Chang, J. G., Raudensky, M. and Horsky, J., 1995, "An inverse finite

element evaluation of roll cooling in hot rolling of steels", Journal of Material

Processing and Manufacture Science, Vol. 3, pp. 387-408.

Zajc, D., 1998, "Experimental Study of a Quench Process", M.S. Thesis, Ohio

University.

Page 99: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

Appendix

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / * This program is used to solve the inverse heat conduction * / / * problem. * / / * Written by Rong Zhong * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . #include cstdio.h> #include cmath.h> #include <stdlib.hz #include <imsl.h> #include "nrutil. h1I #define MAX 500

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / * Global Data. * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . int nn, mm; float TINN, tim; float tc [MAXI , qc [MAXI , y y 2 [MAXI , ten [MAXI , Ten [MAXI ;

float L=0.006, / * Length of the plate * / alpha=2e-5, / * Thermal diffusivity * / K=40.0, / * Thermal conductivity * / TIN=400.0, / * Initial temperature * / QC=lOOOOO.O; / * Constant heat flux * /

float err-abs=0.001, err-rel=0.001;

/ * Function Prototype. * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . void spline ( ) ; float splint (float xt) ;

float Q(f1oat t); float DQ(f1oat t); float QEXP(f1oat t); float DQEXP ( float t ) ;

float float [I, float, float); / * calculated ~ ( x , t) * / float ECO (float) ; / * EO * / float ECN (f loat) ; / * En * / float CN (float, float) ; / * Cn * /

Page 100: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

void exampl(int, int, float[], float[]); / * IMSL routine * /

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / / * Main Program. * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / main ( )

int it j , m; int ibtype=O; float *result, fxqt [2OOl , qcguess [MAXI t qcguessd [MAXI 1 qctemp ;

char *fmt="%12.4eU; static float grad-tol=l.Oe-3; float ted [MAXI , Ted [MAXI , tcd [MAXI ; float v, d [MAXI , h [MAXI , qclb [MAXI , qcub[MAXI ;

for (i=0; i<mm; i++) scanf (IT%f %fu, &tcd [i] , &qcguessd [i] ) ;

for (i=O; i<m; i++) scanf ("%f %f &ted [i] , &Ted [i] ) ;

TIN=Ted [ 0 1 ; printf("%f\nU), TIN);

for (i=O;i<mm;i++) printf ("%f %f\n I r , tcd[il , qcguessd [il ) ;

for (i=O;i<mm; i++) { tc [i] =tcd [il *L*L/alpha; qcguess [il =qcguessd [il /QC;

for (i=0; i<mm; i++) { qclb [i]=-1.e6; qcub[i] =l. ;

for (i=O; i<m; i++) { ten [i] =ted [i] *L*L/alpha; Ten [i] =Ted [i] *K/ (QC*L) ;

result=imsl~f~bounded~1east~squares(exampl, m, mm, ibtype, qclb, qcub, IMSL-XGUESS, qcguess, IMSL - GRAD-TOL, grad-tol, IMSL-RETURN-USER, qc, 0

) ;

exampl (m, mm, result, fxqt) ;

for (i=0 ; i<mm; i++) { printf ("%f %f \nu, tcd [i] , qc [i] *QC) ;

Page 101: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

for (i=O;i<mm; i++) { h [il =-qc [il *QC/ (TT (qc, tc [i] , 1. ) *Qc*L/K-25. ) ; printf ( "%f %f \nu, tcd [i] , h [i] ) ;

for (i=0 ; icm; i++) { v=TT (qc, ten [i] , 0. ) ; d [i] =v*QC*L/K;

1 for (i=~;i<m; i++) { printf ("%f %f %f \nll, ted [i] , d [i] , Ted [i] ) ;

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / * This program is used to evaluate the function that defines the * / / * least-squares problem. * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . void exampl(int m, int mm, float qctemp[], float f[]) { int i;

for (i=O;i<m;i++) { tim=ten [il ; f [i] = (Ten [i] -TT (qctemp, ten [i] , 0. ) ) ;

/ * This program is used to calculate the temperature T(x,t) over * / / * the entire plate at any instant. * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / float TT (f loat qcx [I , float t, float x) { float cn,tr,cO,e01,e02,value~eO; int i;

for (i=0; i<mm; i++) qc [il =qcx [il ;

spline ( ) ; e01=Q (0. ) /3. ; e02=-Q (0. ) /4. ;

/ * integration of xA2 term * / / * integration of xA3 term * /

value - e0=imsl~f~int~fcn~smooth(ECO, O., I., IMSL-ERR-ABS, err-abs, IMSL-ERR-REL, err-rel, O)+eOl+e02; / * EO term * /

cO=imsl-f-int-fcn-sing(Q, O., t, IMSL-ERR-ABS, err-abs, IMSL-ERR-REL, err-rel, O)+(l./l2.)*Q(t)-(1./12.)*Q(O.)+value~eO;

/ * CO term * /

Page 102: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

cn=CN(t,x) ; tr=Q (t) * (pow (x, 3) -x*x) ;

/ * Cn term * / / * Transformation term * /

return cO+cn+tr;

/ * This program is used to get Cn(x,t) of the analytical solution. * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / float CN(f1oat t, float x) 'l

float sumt=0.0, sum=0.0; int s=l; float an, bn, enl, en2; float value-QEXP, value - DQEXP, value-ECN;

nn=l; do I S=-s; an=12. * (s-1) / (~~*~~*M-PI*M-PI) ; / * An term * / bn=-2. * (s* (nn*nn*M - PI*M-PI-6. ) +6. ) / (pow (nn*M-PI, 4) ) ; / * Bn term * /

value - ~~XP=imsl-f-int-fcn(QEXP, O., t, IMSL-ERR-ABS, err-abs, MSL - ERR-REL, err-rel, 0);

value - DQEXP=~~S~-f-int-fcn-sing(DQEXP, O.,t, IMSL-ERR-ABS, err-abs, IMSL - ERR - REL, err-rel, 0);

enl=-Q (0. ) * (6. *s/pow (nn, 2) +12. / (pow (nn, 4 ) *M-PI*M-PI) * (1-s) ) ; / * integration of xA2*cos term * /

en2=Q(O.) *4*s/pow(nn, 2) ; / * integration of xA3*cos term * / / * Initial term of En * /

value-ECN=imsl-f-int-fcn-trig(ECN, O., I., IMSL-COS, nn*M-PI, 0) "2. + (enl+en2) / (M - PI*M - PI) ;

/ * En term * / sum=(an*value QEXP+bn*value DQEXP+value-ECN*exp(- pow (nn*M - PI, 2)*t) ) *cos (~~*M:PI*X) ; surnt+=sum; if (abs (sumt) el. 0e-4) break ;

if (abs (sum/sumt) el. 0e-4) break;

nn++; if (nn==499) printf("Warning! ! Convergence Problem!");

)while (nnc500) ;

return sumt;

Page 103: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

/ * This program is used to get constant term EO(x). * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . float ECO (float x) { TINN=TIN*K/ (QC*L) ; return TINN;

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / * This program is used to get constant term En(x). * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . float ECN (float x)

TINN=TIN*K/ (QC*L) ; return ~1~~*cos(nn*M_PI*x);

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / * This program is used to get q(t) term. * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . float Q(f1oat t) I float value; value=splint (t) ; return value;

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / * This program is used to get dq(t)/dt term. * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . float DQ(f1oat t) I float step[20], value; int i=O ;

step [i] =tc [i+ll -tc [i] ; value=yy2 [i] * (-3. *tc [i+l] *tc [i+l] +6. *tc [i+l] *t-

3. *t*t) / (6. *step [il ) +yy2 [i+1] * (3. *t*t-6. *t*tc [il+3. *tc [il *tc [il ) / (6. *step [i] ) - (qc [i] /step [i] - step [i] /6. *yy2 [il ) + (qc [i+ll /step [il -step [i] /6. *yy2 [i+l] ) ;

return value;

Page 104: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

/ * This program is used to get q(t)*exp term. * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . float QEXP(f1oat t) i return Q(t) *exp(pow(nn*~ - PI,2)* (t-tim)) ; 1

/ * This program is used to get (dq/dt)*exp term. * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . float DQEXP (float t) I return DQ(t)*exp(pow(nn*M-PI,2)*(t-tim)); 1

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / * This program is used to call spline function. * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . void spline ( )

L

int i, k; float p, sig, Xu;

for (i=l;i<mm-l;i++) { sig= (tc [il -tc [i-11 ) / (tc [i+ll -tc [i-11 ) ; p=sig*yy2 [i-1]+2.0; yy2 [il= (sig-1.0) /p; u [il= (qc [i+ll -qc [il ) / (tc [i+ll -tc [il ) - (qc [il -qc [i-11 ) / (tc [i] -tc [i-l] ) ; u [il = (6.0"~ [ill (tc [i+ll -tc [i-11 ) -sig*u [i-11 ) /p;

1 yy2 [mm-11 =O.O; for (k=mm-2; k>0; k--) yy2 [kl =yy2 [kl *yy2 [k+l] +u [k] ;

/ * This program is used to call splint function. * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / float splint(f1oat xt) { void nrerror (char error-text [I ) ; int klo, khi , k; float h,b,a,yt;

Page 105: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

while (khi-klosl) { k= (khi+klo) s>l; if (tc [kl >xt) khi=k;

else klo=k; J

h=tc [khi] -tc [klol ; if (h==O. 0) nrerror ("Bad xx input to routine splint") ; a= (tc [khil -xt) /h; b= (xt-tc [klol ) /h; yt=a*qc [klo] +b*qc [khi] + ( (a*a*a-a) * y y 2 [klo] + (b*b*b- b) * y y 2 [khi] ) * (h*h) /6.0; return yt; 1

Page 106: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / * The header file nruti1.h. * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . #ifndef - NR - UTILS - H- #define - NR-UTILS-H-

static float sqrarg; #define SQR (a) ( (sqrarg= (a) ) == 0 . 0 ? 0 . 0 : sqrarg*sqrarg)

static double dsqrarg; #define DSQR(a) ((dsqrarg=(a)) == 0 . 0 ? 0 . 0 : dsqrarg*dsqrarg)

static double dmaxargl,dmaxarg2; #define DMAX (a, b) (dmaxargl= (a) , dmaxarg2= (b) , (dmaxargl) > (dmaxarg2 ) ? \

(dmaxargl) : (dmaxarg2) )

static double dminargl,dminarg2; #define DMIN (a, b) (dminargl= (a) , dminarg2= (b) , (dminargl) < (dminarg2) ? \

(dminargl) : (dminarg2) )

static float maxargl,maxarg2; #define FMAX (a, b) (maxargl= (a) , maxarg2= (b) , (maxargl) > (maxarg2) ? \

(maxargl) : (maxarg2) )

static float minargl,minarg2; #define FMIN (a, b) (rninargl= (a) , rninarg2= (b) , (minargl) < (minarg2) ? \

(rninargl) : (minarg2 ) )

static long lmaxargl,lmaxarg2; #define LMAX (a, b) (lmaxargl= (a) , lmaxarg2= (b) , (lmaxargl) > (lmaxarg2) ? \

(lmaxargl) : (lmaxarg2) )

static long lminargl,lminarg2; #define LMIN (a, b) (lminargl= (a) , lminarg2= (b) , (lminargl) < (lminarg2) ? \

(lminargl) : (lminarg2) )

static int imaxargl,imaxarg2; #define IMAX(a,b) (imaxargl=(a) ,imaxarg2=(b),(imaxargl) > (imaxarg2) ? \

(imaxargl) : ( imaxarg2 ) )

static int iminargl,iminarg2; #define IMIN (a, b) (iminargl= (a) , iminarg2= (b) , (iminargl) < (iminarg2 ) ? \

(iminargl) : (iminarg2))

#if defined (-STDC-) I I defined (ANSI) I I defined (NRANSI) / * ANSI * /

void nrerror (char error-text [ 1 ) ; float *vector(long nl, long nh) ; int *ivector(long nl, long nh);

Page 107: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

unsigned char *cvector(long nl, long nh); unsigned long *lvector(long nl, long nh); double *dvector(long nl, long nh); float **matrix(long nrl, long nrh, long ncl, long nch) ; double **dmatrix(long nrl, long nrh, long ncl, long nch); int **irnatrix(long nrl, long nrh, long ncl, long nch); float **submatrix(float **a, long oldrl, long oldrh, long oldcl, long oldch, long newrl, long newcl) ; float **convert-matrix(f1oat *a, long nrl, long nrh, long ncl, long nch) ; float ***f3tensor(long nrl, long nrh, long ncl, long nch, long ndl, long ndh) ; void free-vector(f1oat *v, long nl, long nh); void free-ivector(int *v, long nl, long nh); void free-cvector(unsigned char *v, long nl, long nh); void free-lvector(unsigned long *v, long nl, long nh); void free dvector(doub1e *v, long nl, long nh); void freeImatrix (f loat **m, long nrl, long nrh, long ncl, long nch) ; void free-dmatrix(doub1e **m, long nrl, long nrh, long ncl, long nch); void free-imatrix(int **mi long nrl, long nrh, long ncl, long nch); void free-submatrix(f1oat **b, long nrl, long nrh, long ncl, long nch); void free-convert-matrix(float **b, long nrl, long nrh, long ncl, long nch) ; void free-f3tensor(float ***t, long nrl, long nrh, long ncl, long nch, long ndl, long ndh);

#else / * ANSI * / / * traditional - K&R * /

void nrerror ( ) ; float *vector ( ) ; float **matrix ( ) ; float **submatrix ( ) ; float **convert-matrix ( ) ; float ***f3tensorO ; double *dvector 0 ; double * *dmatrix ( ) ; int *ivector ( ) ; int **imatrix ( ) ; unsigned char *cvector ( ) ; unsigned long *lvectorO; void f ree-vector ( ) ; void f ree-dvector ( ) ; void f ree-ivector ( ) ; void f ree-cvector ( ) ; void f ree-lvector ( ) ; void f ree-matrix ( ) ; void free-submatrix(); void free-convert-matrix(); void f ree-dmatrix ( ) ; void f ree-imatrix ( ) ; void f ree-f 3 tensor ( ) ;

Page 108: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / * This routine is used by spline and splint routines. * / / * The first routine-nrerror is invoked to terminate program * / / * execution, others are used to allocate and deallocate memory * / / * for vectors and matrices. * / / * Written by "Numerical Recipes in C " * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . #include <stdio.h> #include <stddef.h> #include <stdlib.h> #define NR-END 1 #define FREE-ARG char*

void nrerror (char error-text [I ) / * Numerical Recipes standard error handler * / { fprintf(stderr,"Numerical Recipes run-time error . . . \nH); fprintf (stderr, "%s\n",error-text) ; fprintf(stderr, "...now exiting to system . . . \ nu) ; exit (1) ; 1 float *vector(long nl, long nh) / * allocate a float vector with subscript range v[nl..nhl * / 1

float *v;

v= (float * ) malloc ( (size-t) ( (nh-nl+l+N~_EN~) *sizeof (float) ) ) ; if ( !v) nrerror ("allocation failure in vector 0 " ) ; return V-nl+NR-END;

int *ivector (long nl, long nh) / * allocate an int vector with subscript range v[nl..nh] * / I int *v;

v=(int *)malloc((size t) ((nh-nl+l+N~-END)*sizeof(int))); if ( !v) nrerror (~~allo~ation failure in ivector 0 " ) ; return V-nl+NR-END; 1

unsigned char *cvector(long nl, long nh) / * allocate an unsigned char vector with subscript range v[nl..nh] * / r 1

unsigned char *v; v=(unsigned char *)malloc((size - t) ((nh-nl+l+N~-END)*sizeof(unsigned char))) ; if ( !v) nrerror (I1allocat ion failure in cvector ( ) " ) ; return V-nl+NR-END; 1

Page 109: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

unsigned long *lvector(long nl, long nh) / * allocate an unsigned long vector with subscript range v[nl..nh] * / 1

unsigned long *v; v= (unsigned long * ) malloc ( (size-t) ( (nh-nl+l+NR-END) *sizeof (long) ) ) ; if ( !v) nrerror ( "allocation failure in lvector ( ) 11) ; return V-nl+NR-END; 1 double *dvector(long nl, long nh) / * allocate a double vector with subscript range v[nl..nh] * / t double *v; v= (double * ) malloc ( (size-t) ( (nh-nl+l+NR-END) *sizeof (double) ) ; if ( !v) nrerror (llallocation failure in dvector ( ) " ) ; return V-nl+NR-END; 1 float **matrix(long nrl, long nrh, long ncl, long nch) / * allocate a float matrix with subscript range m[nrl..nrh] [ncl..nch]*/ i long i, nrow=nrh-nrl+l,ncol=nch-ncl+l; float * *m;

/ * allocate pointers to rows * / m= (float * * ) malloc ( (size-t) ( (~~ow+NR-END) *sizeof(float*) ) ) ; if ( !m) nrerror (I1allocation failure 1 in matrix ( ) " ) ; m += NR-END; m -= nrl; / * allocate rows and set pointers to them * / m [nrl] = (float * ) malloc ( (size-t) ( (nrow*ncol+~~-END) *sizeof(f loat) ) ) ;

if ( !m [nrl] ) nrerror (I1allocation failure 2 in matrix ( ) " ) ; m [nrl] += NR-END; m[nrl] -= ncl; for (i=nrl+l; i<=nrh; i++) m [i] =m [i-11 +ncol; / * return pointer to array of pointers to rows * / return m;

double **dmatrix(long nrl, long nrh, long ncl, long nch) / * allocate a double matrix with subscript range m[nrl..nrhl [ncl..nch] * / { long i, nrow=nrh-nrl+l,ncol=nch-ncl+l; double **m; / * allocate pointers to rows * / m=(double * * ) malloc((size-t) ((nrow+~~-~~~)*sizeof(double*) ) ) ; if (!m) nrerr~r(~~allocation failure 1 in matrix()"); m += NR-END; m -= nrl; / * allocate rows and set pointers to them * / m[nrl]=(double * ) malloc((size t) ((nrow*ncol+NR - ~~~)*sizeof(double))); if ( !m [nrl] ) nrerror ("allocation failure 2 in matrix ( ) " ) ;

Page 110: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

m[nrl] += NR-END; m[nrl] -= ncl; for (i=nrl+l; ic=nrh;i++) m[i] =m[i-11 +ncol; / * return pointer to array of pointers to rows * / return m; I

int **imatrix(long nrl, long nrh, long ncl, long nch) / * allocate a int matrix with subscript range m[nrl..nrh] [ncl..nch] * /

L

long i, nrow=nrh-nrl+l,ncol=nch-ncl+l; int **m;

/ * allocate pointers to rows * / m= (int * * ) malloc ( (size-t) ( (~~OW+NR-END) *sizeoflint*) ) ) ;

if (!m) nrerror(llallocation failure 1 in matrix()"); m += NR-END; m -= nrl; / * allocate rows and set pointers to them * / m [nrl] = (int * ) malloc ( (size t) ( (nrow*ncol+~~-END) *sizeof(int) ) ) ; if ( !m [nrl] ) nrerror ("allocation failure 2 in matrix ( ) " ) ; m[nrl] += NR-END; m [nrl] -= ncl;

for (i=nrl+l; ic=nrh; i++) m[i] =m[i-11 +ncol; / * return pointer to array of pointers to rows * / return m; I float **submatrix(float **a, long oldrl, long oldrh, long oldcl, long oldch, long newrl, long newcl) / * point a submatrix [newrl . . I [newcl . . ] to a [oldrl . . oldrh] [oldcl . . oldch] * / { long i,j,nrow=oldrh-oldrl+l,ncol=oldcl-newcl; float **m; / * allocate array of pointers to rows * / m= (float * * ) malloc ( (size-t) ( (~~ow+NR-END) *sizeof (float*) ) ) ; if ( !m) nrerror ("allocation failure in submatrix ( ) " ) ; m += NR-END; m -= newrl;

/ * set pointers to rows * / for (i=oldrl, j=newrl; i<=oldrh; i + + j ++) m [j I =a [i] +ncol; / * return pointer to array of pointers to rows * / return m; 1 float **convert-matrix(f1oat *a, long nrl, long nrh, long ncl, long nch) / * allocate a float matrix m[nrl..nrh] [ncl..nchl that points to the matrix declared in the standard C manner as a[nrow] [ncol], where nrow=nrh-nrl+l and ncol=nch-ncl+l. The routine should be called with the address &a[Ol [Ol as the first argument. * /

Page 111: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

I

long i,j,nrow=nrh-nrl+l,ncol=nch-ncl+l; float * *m; / * allocate pointers to rows * / m=(float * * ) malloc((size-t) ((nrow+NR-END)*sizeof(float*))); if ( !m) nrerror ( "allocation failure in convert-matrix ( ) 11) ; m += NR-END; m -= nrl; / * set pointers to rows * / m [nrl] =a-ncl; for(i=l, j=nrl+l;icnrow;i++, j++) m[jl=m[j-ll+ncol; / * return pointer to array of pointers to rows * / return m; 1 float ***f3tensor(long nrl, long nrh, long ncl, long nch, long ndl, long ndh) / * allocate a float 3tensor with range t[nrl..nrhl [ncl..nchl [ndl..ndhl * /

long i,j,nrow=nrh-nrl+l,ncol=nch-ncl+l,ndep=ndh-ndl+l; float ***t; / * allocate pointers to pointers to rows * / t= (float * * * ) malloc ( (size-t) ( (~~ow+NR-END) *sizeof(float**) ) ) ; if ( ! t) nrerror ("allocation failure 1 in f 3tensor ( ) ; t += NR-END; t - = nrl; / * allocate pointers to rows and set pointers to them * / t [nrl] = (float * * ) malloc ( (size-t) ( (nrow*ncol+NR-END) *sizeof(float*) ) ) ; if ( ! t [nrl] ) nrerror ("allocation failure 2 in f 3tensor ( ) It) ; t [nrl] += NR-END; t [nrl] -= ncl; / * allocate rows and set pointers to them * / t [nrl] [ncll = (float * ) malloc ( (size-t) ( (nrow*ncol*ndep+~~-END) *sizeof(float) ) ) ; if ( ! t [nrl] [ncl] ) nrerror ( I1allocation failure 3 in f 3tensor ( ) ;

t [nrl] [ncl] += NR-END; t [nrl] [ncll -= ndl; for(j=ncl+l;jc=nch;j++) t[nrlI [j]=t[nrl] [j-l]+ndep; for (i=nrl+l; ic=nrh; i++) { t [il =t [i-11 +ncol; t [i] [ncl] =t [i-l] [ncll +ncol*ndep; for (j=ncl+l; j<=nch; j++) t [il [jl =t [il [j-11 +ndep;

/ * return pointer to array of pointers to rows * / return t ; 1

void free-vector(f1oat *v, long nl, long nh) / * free a float vector allocated with vector() * /

L

free ( (FREE-ARG) (v+nl -NR-END) ) ; >

Page 112: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

void free-ivector(int *v, long nl, long nh) / * free an int vector allocated with ivectoro * /

void free-cvector(unsigned char *v, long nl, long nh) / * free an unsigned char vector allocated with cvectoro * / 1

free ( (FREE - ARG) (v+nl-NR-END) ) ;

I void free-lvector(unsigned long *v, long nl, long nh) / * free an unsigned long vector allocated with lvector() * /

void free-dvector(doub1e *v, long nl, long nh) / * free a double vector allocated with dvectoro * /

r

void free-matrix(f1oat **m, long nrl, long nrh, long ncl, long nch) / * free a float matrix allocated by matrix0 * / { free ( (FREE ARG) (m [nrll +ncl -NR-END) ) ; free ( (FREEIARG) (m+nrl -NR-END) ) ; 1

void free-dmatrix(doub1e **m, long nrl, long nrh, long ncl, long nch) / * free a double matrix allocated by dmatrixo * /

iree ( (FREE ARG) (m [nrll +ncl-NR-END) ) ; free ( (FREE-ARG) (m+nrl -NR-END) ) ; -

void free-imatrix(int **m, long nrl, long nrh, long ncl, long nch) / * free an int matrix allocated by imatrix0 * /

iree ( (FREE-ARG) (m [nrll +ncl-NR-END) ) ; free ( (FREE-ARG) (m+nrl -NR-END) ) ;

1

void free-submatrix(f1oat **b, long nrl, long nrh, long ncl, long nch) / * free a submatrix allocated by submatrix0 * / I free ( (FREE-ARG) (b+nrl -NR-END) ) ; 1

void free-convert-matrix(float **b, long nrl, long nrh, long ncl, long nch) / * free a matrix allocated by convert-matrix() * /

Page 113: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

void free-f3tensor(float ***t, long nrl, long nrh, long ncl, long nch, long ndl, long ndh) / * free a float f3tensor allocated by f3tensor() * / 1

free ( (FREE-ARG) (t [nrl] [ncll +ndl-NR-END) ) ; free((FREE-ARG) (t[nrl]+ncl-NR-END)); free((FREE-ARG) (t+nrl-NR-END)); 1

Page 114: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

/ * This program is for constant q(t) to be used to compare with * / / * the result in Beck book in the direct problem. * / / * Written by Rong Zhong * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / * Global Data. * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / int nn; float L=0.006,

alpha=2e-5, K=40., TIN=O., / * dimensional initial temperature * / TINN, / * non-dimensional initial temperature * / QC=lOOO., tim;

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / / * unction Prototype. * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . float qgaus (float (*func) (float) , float a, float b) ; float (*p) (float);

float Q(f10at t); float DQ (f loat t) ; float QEXP(fl0at t) ; float DQEXP (float t) ;

float TT (f loat x, float t) ; / * calculated t * / float ECO(f1oat); / * e0 * / float ECN (float) ; / * en * / float CN(float, float) ; / * cn * /

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / * Main Problem. * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . main ( ) { float value,tt,ttd,x,xl; float vl,v2,v3,v4,v5; float vdl,vd2,vd3,vd4,vd5; printf ("Input the time (dimensional) : " ) ; scanf ( I1%£ 'I, &ttd) ;

Page 115: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

tt=ttd*alpha/ (L*L) ; tim=tt; TINN=TIN*K/ (QC*L) ; printf ("tt=%f\nU, tt) ; vl=TT(tt,l.) ; v2=TT(tt,0.75) ; v3=TT(tt,0.5) ; v4=TT (tt, 0.25) ; vS=TT(tt,O.) ; V~S=VS*QC*L/K; vd4=v4*QC*L/K; vd3=v3 *QC*L/K; v~~=v~*Qc*L/K; v~~=v~*Qc*L/K; printf ("ttd=%f, tt=%f \nl', ttd, tt) ; printf("The non-dimensional values are:"); printf ("\n%f %f % f %f %f\n11,vl,v2,v3,v4,v5); printf("\nThe dimensional values are:"); printf ("\n%f %f % f %f %f\nI1,vdl, vd2, vd3, vd4, vd5 ) ;

J

float TT(f1oat t, float x)

float cn,tr,cO,e01,e02,value~eO; e01=Q (0. ) /3. ; e02=-Q (0. ) /4. ; p=ECO ; value-eO=qgaus (p, 0. , 1. ) +e01+e02;

tr=Q (t) * (pow (x, 3 ) -x*x) ;

return cO+cn+tr;

1 float CN(f1oat t, float x)

i float sumt=0.0, sum=0.0; int s=l; float an, bn, enl, en2; float value-QEXP, value-DQEXP, value-ECN; nn=l; do I S=-s; an=12. * (s-1) / (nn*nn*M-PI*MMPI) ; bn=-2. * (s* (nnXnn*M-PI*M - PI-6. ) +6. ) / (pow (nnXM-PI, 4) ) ;

p=QEXP; value-Q~XP=qgaus(p, O., t);

Page 116: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

sum=(an*value~QEXP+bn*value~DQEXP+value~ECN*exp(- pow (nn*M-PI, 2) *t) ) *cos (~~*M-PI*x) ;

sumt+=sum; /*if (abs (sumt) <lOe-4) break;

if (abs (sum/sumt) <lOe-8) break; * /

nn++ ; /*if (nn==499) print f ( "Warning ! ! Convergence Problem! ) ; * /

}while (nnc500) ;

return sumt; 1

float ECO (float x)

return TINN; 1

float ECN(f1oat x) r 1

return ~~NN*cos(nn*M-PI*x);

1 float Q(f1oat t)

return 1000.O/QC;

float DQ(f1oat t)

return 0. ; J

float QEXP(f1oat t)

return Q (t) *exp (pow (nn*M-PI, 2) * (t-tim) ) ; J

float DQEXP (float t)

return DQ (t) *exp (pow (nn*~-PI, 2) * (t-tim) ) ;

Page 117: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

J

float qgaus(f1oat (*func) (float), float a, float b)

int j; float xr,xm,dx,s; static float x[]={0.0, 0.1488743389, 0.4333953941, 0.6794095682, 0.8650633666, 0.9739065285); static float w[]={0.0, 0.2955242247, 0.2692667193, 0.2190863625, 0.1494513491, 0.0666713443);

xm=O. 5* (b+a) ; xr=O. 5* (b-a) ; s=o; for(j=l; jc=5; j++) { dx=xr*x [ j I ; s+=w[j] * ( (*func) (xm+dx) + (*func) (xm-dx) ) ;

1 return s*=xr;

Page 118: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / * This program is used to calculate the temperature distribution * / / * of one bar by using finite difference method. * / / * Written by ROng Zhong * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / * Global Data. * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . float L=0.006, alpha=2.0e-5, K=40., TN 1251 , TO [25] , T N ~ [25] , TN2 [25] ,

TIN=400. ;

/ * Function Prototype. * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . float Q(f1oat t);

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / * Main Program. * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . main ( 1 I float deltax=0.0003, deltat, C,tl, tim=O.; int n, i;

printf("P1ease enter total time:"); scanf ("%fH, &tl) ; n=20; print£ ( I1Please enter deltat : " ) ; scanf ( " % f n , &deltat) ;

for (i=0 ; i<=n; i++) { TO [i] =TIN;

do I TNl [0] =TO [0] +C* (2. *TO [l] -2. *TO [O] ) ; TNl [n] =TO [n] +C* (2. *TO [n-l] -2. *TO [n] + ( Q (tim) /K) *2. *deltax) ;

for (i=l; i<n; i++) { TNl [i] =TO [i] +C* (TO [i+l] -2. *TO [i] +TO [i-l] ) ;

J

TN2 [0] =TO [0] +C* (2. *TNl [l] -2. *TN1 [O] ) ;

Page 119: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

TN2 [n] =TO [n] +C* (2. * T N ~ [n-l] -2. * T N ~ [n] + (Q (tim+deltat) / K ) *2. *deltax) ; TN [0] = (TNl [O] +TN2 [o] ) /2. ; TN [n] = (TNl [n] +TN2 [nl ) /2. ;

for (i=l; icn; i++) { TN2 [i] =TO [i] +C* (TN1 [i+l] -2. *TNl [i] +TNl [i-11 ) ; TN [i] = (TNl [i] +TN2 [il ) /2. ;

for (i=o; ic=n; i++) { TO [i] =TN [i] ;

for (i=0 ; ic=n; i++) { ~rintf ("%e\tM,~N[i] ) ;

printf ("\n") ;

J

float Q(fl0at t)

{ return 10000.*t*t;

1

Page 120: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

/ * This program is for variable q(t) to be used to compare with * / / * finite difference method in the direct problem. * / / * Written by Rong Zhong * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . /

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / * Global Data. * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / int n; float L=0.006, alpha=2e-5, K=40., TIN=400.,TINN, QC=1000., tim, FM=10000.;

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / * Function Prototype. * / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . float qgaus(f1oat (*func) (float) ,float a, float b); float (*p) (float);

float Q(f1oat t); float DQ(fl0at t) ; float QEXP (float t) ; float DQEXP (float t) ;

float TT (f loat x, float t) ; / * calculated t * / float ECO (float) ; / * e0 * / float ECN (float) ; / * en * / float CN (float, float) ; / * cn * /

/ * Main Program. * . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . main ( ) I

iloat value,tt,ttd,x,xl; float vl,v2,v3,v4,v5; float vdl,vd2,vd3,vd4,vd5; float ttmp[61={0.01, 0.05, 0.1, 0.2, 0.3, 0.4); int i; printf("1nput the dimensional time: " ) ; scanf ("%fU, &ttd) ; tt=ttd*alpha/ (L*L) ; tim=tt; TINN=TIN*K/ (QC*L) ;

Page 121: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

printf ("tt=%f\nU, tt) ; vl=TT(tt, 1. ) ; v2=TT(tt, 0.75) ; v3=TT(tt,O.5) ; v4=TT(tt, 0.25) ; v5=TT (tt, 0. ) ; vd5=v5*QC*L/K; vd4=v4*QC*~/K; v~~=v~*Qc*L/K; v~~=v~*Qc*L/K; V~I=VI*QC*L/K; printf (I1ttd=%f, tt=%f\nl', ttd, tt) ; printf ("The non-dimensional values are : ") ; printf (I1\n%f %f % f %f %f \nu ,vl, v2, v3, v4, v5 ) ; printf("\nThe dimensional values are:"); printf ("\n%f %f % f %f %f \nu, vdl, vd2, vd3, vd4, vd5 ) ;

1

float TT(f1oat t, float x)

I float cn,tr,cO,e01,e02,value~eO; e01=Q (0. ) /3. ; / * integration of xA2 term * / e02=-Q(0.)/4.; / * integration of xA3 term * / p=ECO ; / * initial term * /

value-eO=qgaus(p, O., l.)+eOl+e02; / * EO term * /

P=Q; cO=qgaus (p, O., t) +(l./l2.)*Q(t) - (l./12.)*Q(O.)+value_eO; / * CO term * /

cn=CN(t,x) ; / * Cn term * /

tr=Q (t) * (pow (x, 3) -x*x) ; / * Transformation term * /

return cO+cn+tr;

float C~(float t, float x)

I float sumt=0.0, sum=0.0; int s=l; float an, bn, enl, en2 ; float value-QEXP, value-DQEXP, value-ECN; n=l;

do I s=-s; an=12. * (s-1) / (n*n*M-PI*M-PI) ; / * An term * / bn=-2. * (s* (n*n*M-PI*M-PI-6. ) +6. ) / (pow ( n * - PI, 4) ) ; / * Bn term * /

p=QEXP; value-QEXP=qgaus(p, O., t);

Page 122: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

enl=-~(0.) * (6.*s/pow(n,2)+12./ (pow(n,4) * - PI*M-PI) * (1-s) ) ; / * integration of xA2*cos term * / en2=Q (0. ) *4*s/pow (n, 2) ; / * integration of xA3*cos term * /

p=ECN; / * Initial term of En * /

value-ECN=qgaus (p, O., 1. ) *2. + (enl+en2) / (M-PIXMMPI) ; / * En term * /

sum=(an*value ~Ex~+bn*value-~QEXP+value-EcN*exp(- pow (n*M-PI, 2)"'~) ) *cos (n*M-PI*x) ; sumt+=sum; n++; }while (nc500) ;

return sumt;

float ECO (float x)

I return TINN;

1 float ECN (float x)

{ return TINN*COS(~*M-PI*X); 1

float Q(f1oat tt)

float t=tt*l*L/alpha; return ~*~*FM/Qc;

float DQ(f1oat tt)

I float t=tt*~*~/alpha; return ~*FM*~/QC;

J

float Q~XP(f1oat t)

I return Q(t) *exp(pow(n*M-PI,2) * (t-tim)) ; 1 float DQEXP (float t)

1

return DQ(t)*exp(pow(n*M-PI,2)*(t-tim)); 1

Page 123: M.S.thesis Zhong_Inverse Algorithm for Determination of Heat Flux

float qgaus(f1oat (*func) (float), float a, float b)

int j ; float xr,xm,dx,s; static float x[]={0.0, 0.1488743389, 0.4333953941, 0.6794095682, 0.8650633666, 0.9739065285); static float w[]={0.0, 0.2955242247, 0.2692667193, 0.2190863625, 0.1494513491, 0.0666713443);

xm=O. 5* (b+a) ; xr=O. 5* (b-a) ; s=o; for(j=l; j<=5; j++) { dx=xr*x [ j I ; s+=w [j] * ( (*func) (xm+dx) + (*func) (xm-dx) ) ;

J

return s*=xr;

1