Beruflich Dokumente
Kultur Dokumente
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
Kumar Anagurthi
March, 1999
OHIO UNIVERStrv
LiBRARY _._~
Acknowledgment
ii
Table of Contents
Chapter 1
Introduction
1.1
Overview
1.2
1.3
Organ.ization of Thesis
Chapter 2
Literature Review
2.1
2.2
Chapter 3
Inverse Determination of the Thennal Conductivity
3.1
Introduction
3.2
3.3
12
3.4
Mathematical Formulation
13
iii
3.5
Algorithm
15
3.6
Error .An.alysis
20
3.7
Examples
21
3.8
Conclusions
28
Chapter 4
Experimental Method
4.1
Experimental Procedure
30
4.2
Tools
33
4.3
Experimental Results
36
Chapter 5
Inverse Determination of Heat Flux
5.1
Definition of Problem
39
5.2
41
5.3
55
5.4.
62
5.5.
67
iv
Chapter 6
Conclusions and Recommendations for Future Work
71
Abstract
73
References
75
Appendix
Appendix A
78
Appendix B
143
List of Tables
3.1
22
5.1.
68
vi
List of Figures
Figure 3.1.
10
Exam.ple 1
23
24
26
27
34
35
36
vii
Figure 4.3.1
Experimental curve
38
Figure 5.1
One-dimensional bar
39
Figure 5.5
69
Figure 5.6
70
Chapter 1
Introduction
1.1 Overview
If the heat flux or temperature histories at the surface of a heated solid are known
as a function of time, then the temperature distribution inside the solid body can be
found. This method is called "direct problem". Conversely, a surface flux history can be
estimated from
"inverse technique". Our problem is to estimate the surface heat flux of a complex object
given the body's temperature history. The problem is attacked here for a one-dimensional
heat conduction problem only.
In high-speed flight (as in spacecraft re-entry), shock wave interaction with the
spacecraft can produce enormous fluxes which can damage aerospace vehicles. To study
these fluxes, the phenomenon is simulated in hypersonic wind tunnels. Ordinarily in these
situations, however, one cannot measure the flux. Therefore, one could measure the
temperature and do computations to recover the heat flux.
Theoretically the problems of determining the surface temperature and the surface
heat flux histories are equivalent in the sense that if one is known the other can be found
in a straightforward fashion. The inverse heat conduction problem, however, is much
more difficult to solve, both analytically and numerically, than the direct problem. The
process of "backing out" the heat flux; i.e., the inverse heat conduction problem, is
10
procedures, such as the finite difference and the finite element methods, have also been
employed due to their inherent ability to treat nonlinear problems. Exact solutions were
proposed by Burggraf [14], Imber and Khan [15], Langford [16], and others. The IHCP is
one of many ill-posed problems, and these are extremely sensitive to measurement errors.
In 1963, Tikhonov [17] introduced regularization method to reduce those sensitivities of
ill-posed problems to measurement errors.
The purpose of this thesis is to provide a general description of various aspects of
IHCP, as well as to introduce a different approach to inverse heat conduction and related
problems.
Criteria for evaluation of IHCP methods [18] are as follows:
1. The predicted temperature and heat fluxes should be accurate if the
measured data are of high accuracy.
2. The method should be insensitive to measurement errors.
3. The method should be stable for small time-steps. This permits the
extraction of more information regarding the time variation of surface
conditions than is permitted by large time steps.
4. Temperature measurements from one or more sensors should be permitted.
5. The method should not require continuous first-time derivatives of the
surface heat flux. Furthermore, step changes or even more abrupt changes
11
12
Cbapter2
Literature Review
in terms of an infmite series of all order derivatives of both T(t) and q(t) and was found
for some very simple geometries, such as a circular cylinder or a sphere.
13
However exact solutions have many practical limitations, such as
1. High-order derivatives of discrete temperature data T(t) and heat flux
q(t) must be evaluated numerically.
5. The method does not lend itself readily to the case of multiple heat flux
determination, such as the two-dimensional case.
Although the above exact solution has limited applicability in a practical sense, it is
extremely important because of the insights provided.
Kover'yanov [19] developed results for the hollow cylinders and spheres. The
heat flux at the exposed surface was determined by differentiating the temperature field.
Imber and Khan [15] obtained an exact solution for the temperature field using Laplace
transforms when the temperature was known at two distinct interior points. Their
temperature solution can be extrapolated in both directions toward the boundaries. The
extrapolation distance is limited to the distance between the two temperature sensors. No
computational results were presented for the more difficult problem of calculating heat
flux at the exposed surface.
14
15
widely used methods for solving the nonlinear transient heat conduction equation are the
fmite difference and finite element methods.
To conclude, this chapter has given a brief description of some of the most
frequently used approaches used to find both exact and approximate solutions and their
basic properties. The next chapter will explain the general problem of determination of
thermal conductivity of inverse heat conduction for a known temperature profile.
16
Chapter 3
Inverse Determination of the Thermal Conductivity
3.1 Introduction
This chapter will describe some of the most important features of the problem of
determination of thermal conductivity for inverse heat conduction for a given temperature
profile. Analysis and the algorithm developed in this chapter are based on results
published in Reference [1]. This study should help obtain a clearer idea about the inverse
heat conduction problem, its basic features, and the associated difficulties when one
attempts to determine heat flux from a known temperature profile.
Most of the studies on inverse determination of the thermal conductivity from
measured temperature profiles assume that the thermal conductivity is only a function of
the spatial coordinate. However, thermal conductivity is a temperature-dependent
quantity in most practical engineering applications. The paper [1] presents a second order
accurate finite difference procedure for the determination of the thermal conductivity that
can be a constant or a spatially or temperature varying quantity. The approach is limited
to a one-dimensional problem only.
problem with heat generation. Figure 3.1 depicts the one-dimensional region R under
consideration. The temperature distribution of the medium is initially prescribed over R3
17
=0
outside of the region is assumed to be at zero temperature. In addition, the product of the
material density and heat capacity is considered as unity.
t
~ ={x,t):x=Qt>o}
~ ={(x,t):x=tt>q
~-
R={(.x;t):O<x<~t>O}
Time
R1
~ ={(.l;t~~t=4
R:z
Spatial Coordinate
Nomenclature:
arbitrary constant
temperature [ C ]
t;
18
timers]
time index
j
space index
(3.1)
T(x,O)
=f
m (x)
for 0 ~ x
(3.2)
1.
1.
2.
3.
ax )
the surface(s).
19
The
any point
k(x, t) at
x within the domain R = {(x, t ): 0 < x < 1,t > O}, assuming that the temperature
tt, t) is known at discrete grid points. This is called the inverse determination of
thermal conductivity.
can also be
ax J2;
ax ,iJr)
at
(iJr ,
~[k(
( )
ax x.t )iJr(x,t)]=iJr(x,t)_
ax
at
g x.t
(3.3)
(3.4)
20
(3.5)
[k(X,t)c7r~,t)] =C
(3.6)
i.e.,
k(.x,t)= c7r(x,i)
(3.7)
ox
where C is a constant. Since C is arbitrary, this implies an infinite number of solutions for
the homogeneous equation. Therefore, the necessary condition for the unique solution
k(x, t) of the ordinary differential Equation (3.5) is: There exists Xo in the interval [0,1],
such that
(3.8)
21
=0,1,2..,N and
N&
= j&, where
interior point and the governing equation is fixed at this particular point. Based on (3.3)
there follows
sr'- a
atI
ax
[k(x t )dI'(x,t)]i -g
_ (x t )i'
ax
'
(3.9)
(3.11)
22
~[k
_I' r, dT. i -Ti)+ki{T i _3~i +2T/\1
0
ax dT
ax Ji0 =
- Ax2 1!'1 \ 1
0\2
1
oJJ
(3.12)
Hence, the finite difference equation at the boundary surface R, takes the form
(3.13)
(3.14)
..
T~'+1 -T~'
2
(
At
g~
(3.15)
3.5 Algorithm
Suppose we are interested in solving the inverse heat conduction problem at
t=t
by assuming a temperature T(x,t), which is known only at the grid points. Using
Equations (3.10), (3.14) and (3.15), one arrives at the linear algebraic system
23
(3.16)
Ax=b
where A is (N+l)-by-(N+l) and is defined as
a.
aO,1
a.
a.,
au
A=
aN-J..N-2
aN-J..N-l
aN-l.N
aN,N-l
aN.N
bo
Xo
x=
b=
(3.17)
(3.18)
24
The above requirements are equivalent to the necessary condition given by Equation
(3.8).
At the boundary surface R1 , i.e., for j
aO,O
(3.19)
(3.20)
(3.21)
For intermediate points, i.e., j = 1,2,....N -1 , Equation (3.10) can be written in the form
(3.22)
(3.23)
0- r{x 0
(3.24)
i-I'
(3.25)
At the boundary surface R2, i.e., for j
(3.27)
(3.28)
Case (2): The temperature data and heat flux at x = 0 are available.
Here the temperature and heat flux is given at x
(3.10) and (3.15) change their forms.
25
= 1,
(3.30)
bo= T(~,t)~T(xo,t)
(3.31)
(3.35)
At the boundary surface R2, i.e., forj = N, Equation (17) takes the form
(3.36)
(3.37)
(3.38)
(3.39)
26
(3.40)
(3.41)
=1,2....N -1,
become
(3.42)
(3.43)
(3.44)
b, - 4Llx
~t
= 1,
(3.47)
ass- = 0,
bn
(3.45)
= T(XN,n!T(XN_t,n
(3.48)
Ax
27
k~_l Vl-l - Tl+1 )+ 4k~ (Tl+1 - 2Tl +Tl-1 )+k~+l (Tl+1 - Tl-1 )
- 4&2 [((Tt
(3.49)
If we let At =&2 , then the local truncation error (LTE) within the interior points due to
the finite differencing is 0 (Ax 3) . Similarly, analyzing LTE at left boundary R] using
Equation (3.14) leads to
(3.50)
If we let At = &2 , then the local truncation error (LTE) at the R, boundary surface due
to the finite differencing is 0(&2). Similarly, at R2 the LTE is 0(&2).
Consequently, the error of the discretization of the governing equation over the
domain R URI U R 2 is &2. Therefore, the system of linear Equations (3.16) is
different from the original equation by an error 0(&2), i.e.,
(3.51 )
28
3.7 Examples
The finite difference procedure described above for the inverse determination of
the thermal conductivity in a one-dimensional heat conduction domain was programmed
29
BllUlld~lr)
\
J11 i t i ~ 1I
I, \
\ = I
I)
T=O
T=O.36te- t
T=O
T =O.16te-t
dT = n:e-
tr2t
ax
T =ge-t
q =-54e-t
T=O
-+T=
sin(O.8n)
~ nu lit ion
sin(nx)
0
cosn{x - 0.8)
aT
ax
I' j
e-,rt[cos(0.2/r) -/rsin(0.2/r)]
T =4e-t
T =e- t sin(l)
(x-3'/
sin(m)
E\~lJlll)f\.
f lc.u
gl\nl'r~ltiull \~(.\, I)
1
2
}-4(X-O.3)2
Tcmpcr.uurc
profile JOt \. I)
t \lIHlUl'li\ it)
l.( " !)
e-2,rt sine1fX)
(x-O.6Yte- t
1+
O.25e-4 (x -0.3)2
}te-t
2'
1
I-T(x,t)
r t
(x - 3)2e- t
(x - 3)2
-O.5e-t sin(x)-
: sin(x)
0.5(1 +T)
30
Example 1:
Consider a slab, 0 ~ x
~ 1,
temperature.
The thermal conductivity is calculated by dividing the region 0 ~ x
fi
.e
10
9
8
i-
~::s
~.
">
~1
into
--+-Example1
-Example 4
'0
3
2
1
U
Ci
- - -__.....----__....~............._...._ . . . _. .
E
0 +------------....---......,.---e
.c
I-
0.2
0.4
0.6
0.8
= 0.1 and
The results of the thermal conductivity for mesh size Llx =0.1 and t
in Figure 3.2(a).
=0.2
are presented
31
It seems that in this case the thermal conductivity is almost constant. These results
clearly demonstrate that the numerical error decreased with the mesh size. The results
from the present study are in very good agreement with the exact solution [1].
Example 2:
Consider a plane wall, o:s; x :s; 1, initially at zero temperature. For time t > 0 , heat
is generated in the solid at a variable rate of g(x,t), and the boundaries at x
=0 and
--+- Example 2
rre
i:;:
. b
-Example 3
--.- Exam !e 5
1.4
1.2
1
"> 0.8
~
e
8
'tS
0.6
0.4
Ci
E 0.2
o-t-----r----....---......----r------.
I-
o
.c
0.2
0.4
0.6
0.8
32
1 into N
Llx = 0.1, 0.05, and 0.025, respectively. The results of the thermal conductivity for mesh
size Llx =0.1 and t = 0.2 are presented in Figure 3.2(b). Note that the accuracy of the
prediction increases with decreasing grid size, as expected. The calculated thermal
conductivity is compared with the exact function and results are plotted in Figure 3.2(b).
Clearly, these numerical results are in excellent agreement with the technical research
paper [1].
Example 3
and having derivative boundary condition at one side and convection boundary
condition on the other side.
Consider a plane wall,
varies with distance. For time t > 0 , heat is generated in the solid at a variable rate of
g(x,t). The derivative of temperature is prescribed at the boundary x = 0, while the
Llx = 0.1, 0.05, "and 0.025, respectively. The results of the thermal conductivity for mesh
size Llx = 0.1 and t = 0.2 is presented in Figure 3.3(a). For N > 40, the variation in
thermal conductivity values are negligible when compared with corresponding thermal
conductivity values at N
33
2.6
_ 2.4
-+-k(10)
-k(20)
-'-k(40)
2.2
2
'Z 1.8
~ 1.6
"> 1.4
~:s 1.2
"g
1
0.8
ii 0.6 ------E 0.4
.! 0.2
...
0 +----~---,-----~--~-----,
0.2
0.4
0.8
0.6
Example 4:
boundary
Next, consider a plane wall, 0 ~ x
~ 1,
varies with distance. For time t > 0 the boundaries at x = 0 and x = 1are kept at a
prescribed temperature, which varies with time. In addition to the temperature
measurements, the heat flux is also known at the left boundary, x
34
S; 1
into N
intervals having the mesh sizes Llx = 0.1,0.05, and 0.025, respectively.
~
~
0.8
i'>
0.8
0.4
'0.2
--.tr- k(40)
~-----....
-6c
c;
-+-k(10)
-k(20)
Eo+-.---,-----.....---~---r-------,
0.2
0.4
0.6
0.8
35
~ 1,
=0 is kept at zero
which varies with time. In addition to the temperature measurements, the heat flux is
known at right boundary, x = 1. The thermal conductivity is calculated by dividing the
region 0 ~ x
~1
into N
Figure 3.3(b).
3.8 Conclusions
Based on the approach used in [1], a second-order finite difference-based
algorithm has been developed for the inverse determination of the thermal conductivity of
a one-dimensional medium. The unknown thermal conductivity is reconstructed using
available temperature data or a combination of temperatures and surface heat flux. The
algorithm is useful and attractive for heat transfer inverse analysis due to its simplicity,
stability, and high speed. The technique is applicable to linear and nonlinear spatially, as
well as temperature-dependent, thermal conductivities.
This algorithm is based on the assumption of known temperature and heat flux
profiles. But the problem that needs to be solved is to fmd the surface heat flux which
causes a prescribed temperature profile at some locations, and then, based on that flux,
36
fmd the temperature profile over the entire body. This type of determining inverse heat
flux is explained in detail in Chapters 4 and 5.
The next chapter will explain the experimental setup and the experimental
procedure of quenching used for experimental determination of the temperature as a
function of time during quenching.
37
Chapter 4
Experimental Method
This chapter briefly describes the experimental setup used to determine the heat
flux for the inverse heat conduction problem, as well as the results of this experiment
performed by D. Jack [25] and M. Javid [26], graduate students in Mechanical
Engineering at Ohio University. A basic description of the experimental setup and the
main result is presented below. In Chapter 5 (Inverse Determination of Heat Flux) these
results are compared to our analytical model.
38
Each of the thermocouples were sampled every of 0.01 seconds for 2 minutes.
Therefore, 12,000 samples were taken per channel and plotted on a graph with
temperature versus time. This experimental curve was then compared with the analytical
curve, derived from Chapter 5, for the same (Ie and Be) conditions as mentioned above.
This experimental procedure was divided into three phases, as described below:
Phase 1:
Phase 2:
Setting the data acquisition system and removing the probe from
the furnace.
Phase
3~
4.1.1 Phase 1
In the first step, the probe was thoroughly scrubbed with a wire brush to remove
any impurities on the surface and then scrubbed with sandpaper. All connections leading
from the probe to the data acquisition system were thoroughly checked for any loose
connections.
The muffle furnace was fired up and the various settings for a temperature of 400
degrees centigrade (initial temperature) were set on the temperature controller for the
furnace to achieve a steady-state of 400 degrees centigrade. Then the probe was set in the
furnace and the lid was closed so that there was minimum transfer of heat from the
furnace. The probe was set in the furnace until a steady-state was attained, which took
about two hours. After the steady-state was reached, Phase 2 of the experiment was
conducted.
39
4.1.2 Phase 2
This was a critical phase in the experimental procedure because of the following
difficulties:
1. Determining the time before which the data acquisition should be started.
2. Providing sampling rate for the cooling curve.
3. Determining the point where the actual cooling curve started.
The data acquisition system was started one second before the probe was actually
quenched. This resulted in some confusion regarding where the actual cooling curve
started. To determine this, one of the thermocouples was placed at the surface of the
probe, which would behave as a switch and show exactly when the probe hit the water.
Since the set temperature was 400 degrees centigrade, the voltage shown by the k type
thermocouple was in the vicinity of 20mV. Following the recommendation of its
producer, a gain of 250 was set on the data acquisition system. A sampling rate of 100Hz
was set on the data acquisition system since it was desired to get a sample every 0.01
seconds. The data acquisition system was set to take data up to 120 seconds and, hence,
the number of samples was set at 12,000. The sensors monitored were Thermocouples #
3, 4, and 5 at a gain of 250 with a sampling rate of 100Hz and a time of 120 seconds, The
time-interval for collection of data was 0.01 seconds.
4.1.3 Phase 3
In this phase, the prepared steady-state heated probe and the holding apparatus
was immersed into a water tank (Figure 4.2.4.1.) for quenching, running the data
acquisition application programs to measure and record the samples from analog/digital
40
(AID) board, and converting the measured electric voltages to temperature values. Then a
graph was plotted with temperature versus time for a sample data.
4.2 Tools
4.2.1 Data Acquisition System (D.A.S)
Board: D.AS. 1701 ST: 16 single-ended or 8 differential channels, 12 bit resolution,
166.67 Ksamples/sec, Gains of 1,5,50 and 250.
Manufacturer: Keithley Metrabyte
Accessories: EXP 18QQ (expansion accessory) contains 16 differential input multiplexes,
with the differential inputs under the control of and at the speed of the host D.AS. board.
Gains of 1 to 50 of the accessories combines with gains of the D.AS._board to give a total
gain of 1 to 400. It works with the supporting software of the attached D.AS. board.
(AID, D/A), digital 110, and custom I/O port devices high-speed background AID, strip
charts, bar indicators, and numeric displays.
4.2.3 Computer
P5-2oo Professional 200 MHz Pentium processor, 32MB SDRAM, 3.0 GB hard
drive.
41
42
The fifth thermocouple was mounted outside the front plate to determine the
starting point of the cooling curve. Thermocouple #1 was located approximately 0.75
inches above the geometric center. Thermocouple #2 was located at geometric center.
Thermocouple #3 was positioned90 degrees away from thermocouple #1 and 0.75 inches
to the right of the geometric center. Thermocouple #4 was positioned 0.5 inches from the
bottom right-handcomer of the back plate.
A circular hole 0.5 inches in diameter was made on one of the sides and a
stainless steel 304 pipe of 0.5 inch diameter was welded to it, through which
thermocouplescould be brought out of the probe to be connected to the D.A.S. The
furnace used is a muffle furnace with a temperature control. 'The experimentalsetup is
shown in Figure 4.2.4.3.
43
from Chapter 5 for the same (IC and BC) conditions as mentioned above for the
experiment.
44
45
The convective heat transfer stage is initiated when the temperature of the metal
surface drops below the boiling point of the quenchant.
350
300
.a
ie
250
200
150
100
50
0+------------,.------,..------.-------,.----....,
o
20
40
Figure 4.3.1
80
100
120
Experimental curve
The next chapter will explain the analytical solution for this inverse heat
conduction problem and compare it with the experimental results described above.
46
Chapter 5
Inverse Determination of Heat Flux
it is subjected
to heat flux q(L,t) , which is an unknown fun.ction of time which is found, based on a
given temperature distribution at x = 0 .
CJT(x,t) =0
ax
x=o
L
Figure 5.1 One-dimensional bar
x=L
47
1 aT(x,t)
=---a at
(5.1)
=1'0
(5.2)
The boundary conditions correspond to the isolated left-end of the bar and the heat flux
input at the other end (Figure 5.1.).
At x=O;kaT(x,t) =0
(5.3)
At x = L; k aT~;,t) = q(L,t)
(5.4)
ax
where
k - thermal conductivity
q - heat flux
T - temperature
t - time
x - space coordinate
48
causes such a distribution. Also, find the temperature distribution as a function of space
and time, i.e.,
rex, t) over the entire bar at any instant and obeying the heat conduction
(5.5)
(5.6)
m=O
From now on, instead of q(L,t) the notation q(L,t,a m ) will be used as a remainder that
49
ax
ax
(5.7)
kL
(5.8)
Written in terms of lIJ , the governing Equation (5.1) using (5.8) and (5.9) becomes
nonhomogeneous
=Q. aT(x,t) =Q
'ax'
At x = L; k
aT(x, t)
ax
=Q
(5.11)
alp (x, t)
ax
=0
(5.12)
(5.13)
50
Now one needs to solve (5;, 10) subjected to the boundary conditions (5.11), (5.12), and
the initial conditions (5.13). For that, one attempts to use the separation of variables
method and tries
(5.14)
Differentiating (5.14) with respect to
x one gets
aljl(X,t) = x'{xp{t)
(5.15)
ax
(5.16)
X'(xPV)--X(x)G(t)=O
a
(5.19)
such that one arrives at the following boundary value problem to be solved
X"'(x)
X(x)
=..!- i; =-A?
aG
where A, is the eigenvalue to be determined. Hence, one has to solve two equations,
(5.20)
51
X'+A?X=O,
(5.21)
G+aA?O=O,
(5.22)
where a dot sign represent differentiation with respect to time. Solutions of (5.21) and
(5.23) have the general form of
(5.23)
O(t) = Cexp(-lYA?t)
(5.24)
B=O,
(5.25a)
(5.25b)
such that
x (x) = A cos(Ax)
(5.26)
dJp(X,t) O
A'1 1_
Smee
at x = L, ax
=, i.e, - A sm(JU) = 0 , one finds that the eigenvalues sought
are
n1Z
A =-, n = 0,1,2... ,
L
(5.27)
(5.28)
From (5.24) one finds that
(5.29)
52
(5.30)
t)
(5.31)
From the superposition principle, which holds for the linear problems, one finally arrives
at
(5.32)
where
(5.33)
11=0
x one finds
a1Jln
_k
~ - C ()
(n1&
-(x,t)
-t Sln-x
,,=0
11
L
ax
dV/n 2 (x, t) _ ~
ax
k ,,=0
)(n1C'
-I
L)
)(nn ,2I
C ( ) (nn
"t cos - x L
L )
(5.3t~)
(5.35)
53
af/J,.
()
(n1C)
-(x.r)
- = ~C
~
t cos - x
at
(5.36)
,.=0"
nit
nit
nte
L -Cn(t)cos(-x)
- 1 - - :LCn(t)cos(-x)
L ( L)
a
L
2
00
,.=0
00
n=O
(5.38)
In order to solve the above equation, one needs to determine C, (r) . It can be done by
using the orthogonality properties of the eigen functions (5.26). By multiplying (5.38) by
those functions and integrating over the domain, one gets the system of equations to find
Cn(t) as follows. At n = 0 Equation (5.38) becomes
54
q(L,t,a",)a
Co(t) =
L aq(L,t,a m )
(5.41)
at
+ 12k
kL
Co(t)
=-I,
kL
L
+-q(L,t,am)+Const.
m +1
12k
m=O
t",+1
(5.42)
III
=_1.A0 + Const.
(5.43)
12k
The unknown constant can be determined from the initial condition as follows. The
Equation (5.32) is
'1/
(x,t)= !CII(t)COS(n;r x)
(5.44)
n=O
'L!'(T, _!!JL(x
L x )Y
kL
4
3 ~
4
=T, + aoL
o
12k
(5.45)
aoL Lao
To +-=-+Const.
12k
12k
Const. =Ta
(5.46)
55
Equation (5.38) is
ntr
ntc 2 1
ntc
L -C,,(t)cos(-x) - - LC,,(t)cos(T x)
,.=0
L
L)
a,.=o
( 1
00
00
cos( L 1
and integrating from 0 to L
)
r1TX
J
o
~
nn
T1 (n1
1
..J-C,.(t)cos(-x)cos(-x)
- '\I dx - L
,.=0
L )
J ..JC,.(t)cos(-x)cos(-x)dx
~
nx
r1
L
a0
,.=0
(5.48)
At n = r , Equation (5.48) becomes
L 1 L -Q(L,t,a m ) ( 6 L2 )
-C (t) -ntr )2 ---C
-=
-2 cos(nn)-I)
( L
n
2 a n 2
kL2
n tr 2
If
2
+ 1 aq(L,t,a
a m ) 12 [ 4L4 \\n21l'
-6 ) cos(n1l')+6 )~
4
kL
nr:
(5.49)
56
(5.50)
(5.51)
The heat flux is assumed to have the form q(L,t,am) =tamtm . Therefore, Equation
m=O
(5..51) becomes
Cn{t) =exp(- ,
-exp(
'7 J 12a(:~n;-1))
t
-a(7J 1a124~4 (n
t
2
Jr 2
[q(L,t,am)ex p(
a('7 J
t }t]
-6)COS(mr)+6)[dq(L~:,am) exp(a( 7
t }t+E1n )
(5.52)
57
12a(cos(nn-l))
kLn2 n 2
~~-~+
...
o
(5.53)
58
2L
len 4 n4
(n 2n 2 -6) cos(nn)+6
(5.54)
where
12a(cos(nJr -1))
kLn
Assume
E n =E1n +E2n
Jr 2
a(7J-(a(7JJ+
59
VI x, t
+ .J
n=l
) = Tt
+~[~ a
m 1
+
]+Lq(L,t,
am)
12k
kL .J '" m + 1
m=O
12a(cos(nn-l))
kLn
(5.55)
Applying'initial condition on Equation (5.55) to determine E" will fmally yield to the
temperature profile as a function of heat flux. At t = 0
12k
60
(5.56)
land
After using the orthogonality conditions, i.e., after multiply both sides with COS( rtex
L )
integrating from 0 to L and simplifying, one finds En
dq(L,t, am)
d 2q(L,t,a m )
~:;J-(a( :i JJ ~o
+..
61
+~
11=1
T n(L t a )
m
t m +1 ~
'T'
a ~
" m
=.Lo+-~a1ll--+---kL 111=0
1
12k
m+
12a(cos(nJr -1))
2
kLn Jr
00
-:L
11=1
00
-:L
11=1
_ ~ 12a(cos(nn -1))
~
11=1
kLn2
1C
(5.57)
62
2T(x,t)
ax
_ 1 i)T(x,t) = 0
(5.58)
at
00
+:L
n=l
+ f;
~ 2q(L,t,a",)r={JL,(
2 2
6)
( )+6)e ( ,Jntr)2 }.
kn4tr4
~n tr cos nx
xp -~lL t ill
+ ~ 12a(cos(nJ!-1
1:t
kLn
J! 2
dq(L,t,a m )
a( n; J (a( 7JJ
q(L,t,a m )
dt
+ ... exp
(nnxx
L L
ntr )
t s
63
dq(L,t,am )
dt
2q(L,t,a
m)
2
dt
=0;
ClT(x,t) =0
ax
At x = L- ClT(x,t) = q(L,t,am )
'ax
:. T(x,O) = To
where G(x) = a02 (x 3 - Lx 2 ) can be written in Fourier series as
kL
.kL
n1&.
nnx nx
64
\I
=L',G" COS(nnx'
.
00
L )
n=l
while n = 1,2,..
Therefore,
Differentiatmg. . aT,
ax
WIith respect
to x
n 1CX
Xnn
co - - )2
{
L
L
00
+L',
n=l
65
~ 12a(cos(nn -1
+ t
11-1
kLn n
+ q(L,t,a m ) (6x-2L)
kL2
(5.60)
aT(x,t) lYLJ(L,t,a m )
L aq(L,t,a m )
---=
+
kL
12k
at
at
+t
11=1
00
-I
12a(cos(nn -1
22
kLn n
66
~ 2q(L~'2~;~L(n2tr2 -6)cos(ntr)+6)exp(-~:JtI~:J}os(n~)
12a
2(cos(ntr-l))
+ n=l
kW tr
rq(L,t,a
dq(L,t, am)
m)
1~: J
dt
nst
nnx
nx
(5.61)
q(L,t,a m ) (6 2) .
Wntmg
2
~ X - L in the form of the Fourier series
KL
L
o
while at n
KL2
= 1,2...
KL3
67
L =Lo
11
_ 2q
3
n1CX
ntrx
smcos(6x-2l)
L +6
L
-KL
(:J
(nnx '\I
..
Wntmg
s()
X =
Next, let
Then, at n = 0
aKL
L )
at
(5.62)
68
aq(L,t,a m)
at
(X 4
3
Lx )L_
4--3-
KL3 a
-aq(L,t,a m) L4
at
---1-2-K-L3-a- -
-aq(L,t,a m) L
=
at
12Ka
while n = 1,2...
at
L o aKL
"
:. 1 ()q(L,t,am ) (r -LX-)
aKI3
at
(5.63)
ax
1 aT(x,t)
at
(nnx'"
--..J
kL
12k
at
69
=0
This proves that the analytical solution found is the exact one.
m=O
70
+ .J
n=l
Lq(L t a )
', m
12k
12a(cos(nn-) -1)
kLn
1C
dq(L,t, am)
- 2L
dt
21l'2
4 4 (n
-6)cos(n1l')+6
n=l kn 1C
-L
(5.66)
Therefore, differentiating Equation (5.58) with respect to a o at x = 0 , one finds
71
(5.67)
Similarly,
aT(O,t) = Lt + (YJ2 +
allt
12k
2kL
12a(cos(mr-l))
n=1
kLn,2n2
_ ~ 12a(cos(n1&-1))
s:
kLn,2 2
n=l
1&
a(7)
r
]
exp((n1C)2
-a t ) = Ii (t)Lassume
L
(5.68)
72
oT(O,t)
oa2
= Lt 2 + at3 +
12k 3kL
i 12a(cOS~n~-1
kLn
n=l
2t
(2
1!
a(
2t
kL22
1!
(5.69)
oa
73 (t), r4 (t), .. ..
oa
73
to
+aprp(t)+ To -
T~(t)
to (t) =0
3 ) -
To}o (t~)
(5.70)
(5.71)
+ ~ [Ii(to
. (to)+ Ii(tt. (t
1)
+ + Ii (t
. (t
s )]
v. (t.,)]
74
Solving the above linear algebraic system in the coefficients by the Gauss
elimination method, one can find the polynomial coefficients ao, llt ,...am ...a p that are
necessary for describing the heat flux (as a function of time), which produces the given
temperature profile at x
=0 .
simplified form of the probe represents a bar having one-dimensional heat conduction,
which is similar to a bar having the same boundary and initial conditions explained in this
chapter. So, the above solution is suitable to find the analytical temperature profile and
heat flux for this experiment. Using the C program (Appendix B) of this analytical
solution and the experimental data (from experiment), inverse heat flux can be
determined.
As we discussed above, the analytical solution will find the constants ao' a 1 , am .
These constants are coefficients of heat flux polynomial (Equation 5.6). This means we
75
are able to find the heat flux as a function of time at a fixed space (the end of the bar),
which is not possible through the experiment. This is the main advantage of the analytical
solution over the experiment.
For this example the heat flux was assumed as a six degree polynomial function
of time at x = 0 , i.e., Equation (5.6):
6
q(L,t,a 6 ) = I,amt m
m=O
Using the analytical solution described above, the coefficients ao' at, a 2 , , a 6 of heat flux
are calculated and shown in Table 5.1.
76
An analytical temperature curve (5.5) is plotted by developing an analytical
temperature profile for different time steps at x = 0
400
",
~c
300
"
t
l
160
100
50
+---'-----r-~---,.------''--__r_--___,..---..,...___-~
20
eo
eo
100
120
TIme
Figure 5.5
Analytical curve
The experimental data consists of 10,000 temperature data points given in the
time period of interest. In order to get a more efficient result and a smooth curve, the
average of every 100 points is calculated; the corresponding results are presented in
Figure (5.5) for the probe located 10 degrees inclined in furnace. The analytical curve
from Figure (5.5) is next compared with the experimental curve from Figure 4.1
described in Chapter 4. Figure (5.6) shows the comparison. From this curve we can
observe that both analytical and experimental curves are matching each other very well.
77
450
~
Analytical
360
Experimental
300
l~
E 200
150
100
50
0
0
20
40
eo
80
100
120
TIm.
Figure 5.6
78
Chapter 6
. Conclusions and Recommendations for Future Work
This thesis first described differences between direct and inverse heat conduction
(IHCP) illustrated by several numerical examples. The criteria for evaluation of IHCP
methods were discussed as well. The overview of the relevant literature regarding
research of both exact and approximate solutions was also presented.
Next, the problem of determination of the thermal conductivity from measured
temperature profiles was discussed and the corresponding mathematical model for the
inverse heat conduction problem established. The second order accurate finite-differencebased solution algorithm for problems in which a thermal flux can be either a constant or
spatially or temperature varying quantity was then developed and presented for onedimensional problems.
Then, a detailed description of the quench system developed earlier at Ohio
University to collect heat transfer data that will be used in future studies to design quench
processes for optimum heat treating of materials was described. This apparatus had been
used for establishing a correlation between the temperature profile and the corresponding
heat flux input. During a quenching experiment process, the part temperatures and the
cooling rates need to be controlled within certain limits to ensure the formation of
desirable metallurgical properties. Uniform and predictable heat transfer is critical during
a quenching process to minimize the potential for distortion, cracking, and nonuniform
property distribution.
79
80
ABSTRACT
This thesis describes a new technique for solving the inverse heat
conduction problem in a one-dimensional bar. It consists of determination of a heat flux,
which is a function of time and which causes a given, experimentally determined
temperature profile measured at one end of the bar while the other end is kept insulated.
Based on the found heat flux, the temperature profile is then found over the entire bar as a
function of time.
The algorithm combines the separation of the variables method in conjunction
with the least-squares method.
A brief description of the differences between direct and inverse heat conduction
problems are described first, and criteria that must be met by potentially useful IHCP
methods are explained, This is followed by the corresponding literature survey. A general
problem of experimental verification of the theory is discussed next. For illustration, a
problem of determination of thermal conductivity by the finite difference method, based
on the measured temperature profile, is explained in detail.
Next, an experimental setup developed at Ohio University and used to study a
quenching process is described. The time change of temperatures during this process had
been recorded earlier and is regarded as a known function.
In the analytical treatment, the heat flux at the end of the bar is assumed as the
polynomial function of time with the unknown polynomial coefficients. These
coefficients were then calculated by employing the least-squares method to fit the
81
analytically-found solution for the temperature, based on such a flux, and minimizing the
error of such a distribution by comparing it with the experimental data. Finally, this heat
flux is used to find the analytical solution of the temperature profile over the bar as a
function of time. The analytically found temperature profile at the end of the bar was
agreed very well with the experimental curve.
82
References
83
9. Tervola, P., "A method to determine the thermal conductivity from measured
temperature profiles", Int. 1. Heat Mass Transfer 32, pp. 1425-1430 (1989).
10. Chen, W. H. and Seinfeld, J. H., ''Estimation of spatially varying parameters in partial
differential equations", Int. J. Control 15, pp. 487-495 (1972).
11. James, V. Beck, Ben Blackwell, and Charles R. St. Clair, Jr., Inverse Heat
Conduction, ill Posed Problems, A wiley-interscience publication, New York, 1985.
12. Stolz, G., Jr., "Numerical solutions to an inverse problem of heat conduction for
simple shapes", 1. Heat Transfer 82, pp. 20-26 (1960).
13. Mirsepassi, T. J., "Heat-transfer charts for time-variable boundary conditions", Br.
18. Beck, J. V., "Criteria for comparison of methods of solution of the inverse heat
conduction problem", Nucl. Eng. Des. 53, pp. 11-22 (1979).
84
85
APPENDIX A
/**********************************************************************
***********************************************************************
CONSTANT THERMAL CONDUCTIVITY WITHOUT HEAT GENERATION (EXAMPLE: 1)
***********************************************************************
**********************************************************************/
#include<stdio.h>
#include<stdlib.h>
tinclude<math.h>
double
double
l,add;
int
n , i , j;
/* n = No. of intervals, i & j are position
variables in t(time) and x-directions */
int
daubl e
m,k;
x [100]
b[lOO] ,g[lOO] [100];
void title()i
void input();
t [ 100],
/*
86
void xlocations()j
/* Calculating nodal points in x-direction
i.e, X[j] */
void tlocations()j
/* Calculating nodal points in t(time)-direction
i.e. t [ j ] */
void temperaturevalues()j
/* Calculating nodal temperature values */
void heatgenerationvalues()j./* Calculating nodal Heat Generation
values */
void AandBmatrices() j
/* Calculating "AM and" B" matrices at
different x-locations keeping time is constant. Here deltax = 0.1,
deltat = 0.1, and time = 0.2 which means i=2*/
void ThomasElimination() j
/* Applying Thomas Elimination Algorithm */
void AmatrixAfterElimination()j
/* Matrix "A" after Elimination */
void BrnatrixAfterElimination()i
/* Matrix "B" after Elimination */
void ProcessToGetKmatrix()i
/* Back substitution method to get Thermal
conductivity values at differant x-locations */
void thermalconductivityvalues()i
void main (void)
{
title()i
input()i
xlocations()i
tlocations()j
temperaturevalues()j
heatgenerationvalues()i
AandBmatrices()i
ThomasElimination()j
AmatrixAfterElimination()j
BmatrixAfterElimination()i
ProcessToGetKmatrix()i
thermalconductivityvalues()i
}
---- -) i
printf("\n\n)
87
scanf (lI%d
&n) i
/* Enter number of grid points. Assume mesh size is same in x and time
directions i.e. equal to n (which means it is square mesh) */
printf ( .. vnvn~) ;
ll
printf(lIx=\t i
for (j = 0; j <=nj j++)
ll
for (j
* deltax;
x[j] = j
}
= OJ
<=nj j++)
direction */
printf(II%4.2lf\t
ll
x[j])
printf(lI\n")
void tlocations(void)
{
printf("t=\t
for (i = 0; i <=ni i++) {
ll
t[i] = i * deltat;
}
/* Calculating temperature
values at grid locations*/
88
T[j][i]=( exp(-2*M_PI*M_PI * t[i]
* sin(M_PI *
x[j])j /* Temperature Profile */
printf("%10f", T[j] [i])j /* Printing temperature values at all the grid
points */
}
printf ( "\n II
printf(H\n\n")
for(i=Oji<=nji++)
{
g [j] [i) =0 i
printf(U%8.4lf H , g [ j ] [i])j
printf(H\n)i
}
}
void
AandBma~rices()
printf(H\n")i
i=2i /* Here assume deltat = 0.1 which means calculating matrices at
time = 0.2 */
/* Calculating "A" and "E" matrices */
a[O] [0] = T[2] [i] - (3 * T[l] [i]) +( 2 * T[O] [i]);
a[O] [1] = T[l] [i] - T[O] [i];
b[O] = (deltax * deltax) * (T[O] [i+1] - T[O] [i]) / (
del tat) ) -g [0] [i] ) ;
for (j = 1; j <= n; j++) {
a[j][j a [j ] [j]
1]
=4
= T[j
*
1] [i] ) ;
a[j] [j + 1]
= T[j + 1] [i]
T[j
1] [i] ;
+ T [j +
89
b[j} = (4 * deltax * deltax) *
T[j] [i]) / (deltat)) -g[j] [i]) ;
(T[j] [i + 1] -
printf ( \n M) ;
II
printf(lI\n\n
ll
printf("%f\n",b[j])j
}
}
void ThomasElimination()
{
for (k = 0; k <=njk++) {
for (i = k + 1; i <= n; i++) {
a[i] [k] = a[i] [k] / ark] [k];
for (j = k + 1; j <= n; j++)
a[i] [j] = a[i] [j] - a[k] [j] * a[i] [k]
b[i] = b[i] - a[i] [k] * b[k];
}
}}
void AmatrixAfterElimination()
{
II
90
else
printf(NO.OOOOOO ");
}
void BmatrixAfterElimination()
{
void ProcessToGetKmatrix()
{
void thermalconductivityvalues()
{
deltax =
91
/**********************************************************************
***********************************************************************
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
deltax, deltati /* Declaration of input datatypes deltax and
double
deltat */
double
l,addi
int
n, i, ji
/* n = No. of intervals, i & j are position
variables in t(time) and x-directions */
int
m,kj
doub1e
x [ 100], t [ 100], T [ 100] [100], a [ 100] [100] ,
b[100] ,g[lOO] [100] i
void title() j
/* Title of the program */
void input()i
/* Entering deltax, deltat and n */
void x.l ocat i ons t ) : ... /* Calculating nodal points in x-direction i.e.
X[j]
*/
title()i
input()i
xlocations()i
tlocations()i
temperaturevalues()i
heatgenerationvalues()i
AandBrnatrices()i
ThomasElimination()i
AmatrixAfterElimination() j
BrnatrixAfterElimination()j
ProcessToGetKmatrix() j
thermalconductivityvalues()
92
}
printf("x=\t") ;
for (j = OJ j <=nj j++) {
direction */
x[j] = j * deltax;
x-
x[j]);
printf("\n")
void tlocations(void)
{
printf("t=\t H);
for (i = 0; i <=n; i++) {
time-direction */
93
t(i] = i
deltat;
printf(-\n\n")j
}
printf ( .. \n n )
for(i=O;i<=n;i++)
{
printf ( .. vn") ;
[ i] ) } - ( 2 + ( 0 . 5 - 4 * (x [j ] [ i) * exp ( - t [ i] ) ;
94
}
}
T [j ] [i])
T [n] [i] ) i
ben] =( deltax
/( deltat-g[n] [i]);
deltax) * (T[n] [i + 1]
printf("Matrix A:\n\n");
/* Printing IIA" matrix */
for (j = 0; j <=ni j++) {
for (k = 0; k <=nj k++) {
prLnt f t " %8.41f", a[j][k])j
}
pr in t f ( " \ nil) i
}
printf("\n\n) ;
printf("%f\n",b[j]) ;
}
}
- T[n] [ill
95
/* Applying Thomas Elimination Algorithm */
void ThomasElimination()
{
for (k = Oi k <=nik++) {
for (i = k + 1; i <= n; i++) {
a[i] [k] = a[i] [k] / ark] [k];
for (j = k + 1; j <= n; j++)
a[i] [j] = a[i] [j] - ark] [j] * a[i] [k];
b[i] = b[i] - a[i] [k] * b[k];
}
} }
void AmatrixAfterElimination()
{
printf(\n")
}
}
void BmatrixAfterElimination()
{
void ProcessToGetKmatrix()
{
96
add =. b [i] ;
for (k = i + 1; k <= n; k++)
add = add - b[k] * a[i] [k] ;
b [ i ] = add / a [ i] [i] ;
}
void thermalconductivityvalues()
{
97
/*****************************************************************
******************************************************************
TEMPERATURE-DEPENDENT THERMAL CONDUCTIVITY HAVING DERIVATIVE BOUNDARY
CONDITION
AT x=Q DISSIPATING HEAT BY CONVECTION and AT x=l HEAT GENERATION
(EXAMPLE: 3)
******************************************************************
******************************************************************/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
double
deltat */
double
int
variables
void rnain(void)
{
title() j
input() j
xlocations()j
tlocations()j
temperaturevalues() i
heatgenerationvalues() j
AandBmatrices() i
ThomasElimination() ;
AmatrixAfterElimination() ;
98
BmatrixAfterElimination();
ProcessToGetKrnatrix();
therrnalconductivityvalues() ;
}
(EXAMPLE:
\n ) i
printf(-----------------------------------------------------------------_.);
pr Lnt t t s
vnvn ") ;
&n)i
*/
void xlocations(void)
{
printf (x=\ t) ;
for ( j = 0; j <=n ; j ++ ) {
direction */
x[j] = j * deltaxi
printf(\n)j
}
99
/* Calculating and Printing nodal points in t(tirne)-direction i.e t[j]
*/
void tlocations(void)
{
printf(lIt=\t")i
for (i = 0; i <=n; i++) {
time-direction */
t[i] = i * deltat;
printf(lI\n\n
ll
void temperaturevalues(void)
{
printf("\n")i
}
pr i.nt t
t vnvn ") i
v
void heatgenerationvalues()
{
for(j=O;j<=njj++)
locations*/
{
for(i=O;i<=n;i++)
{
100
g [j] [i] = (-M_PI*M_PI*T[j] [i] ) + ( (M_PI*M_PI*T[j] [i]) / (l-T[j] [i] ) )pOW((M_PI*exp(-M_PI*M_PI*t[i)*sin(M_PI*(x[j]-0.8)/(l-T[j] [i] ,2);
printf(II%8.4lf
locations*/
ll,g[j]
[i]);
printf("\n") ;
}
}
II
void AandBmatrices()
{
printf ( II \n II ) ;
i=l; /* Here dltat deltat = 0.1 which means I am calculating matrices
at time = 0.2 */
/* Calculating "All and liB" matrices */
a[O] [0] = T[2] [i] - (3 * T[l] [i]) +( 2 * T[O] [i]);
a[O] [1] = T[l] [i] - T[O] [i] ;
b[O] = (deltax * deltax) * (T[O] [i+1] - T[O] [i]) / (
del tat) ) -g [ 0] [i] ) ;
for (j = 1; j <= n; j++) {
l][i]);
a[j][j + 1] = T[j + 1][i] - T[j - l][i];
b[j] = (4 * deltax * deltax) * ((T[j] [i + 1] T [j] [i]) / (del tat) ) -g [j] [i] ) ;
}
=(
printf(IIMatrix A:\n\n");
/* Printing MAli matrix */
for (j = 0; j <=n; j++) {
for (k = 0; k <=ni k++) {
printf (II %8. 4lf II, a [j] [k) ) ;
}
printf("\n") ;
}
pr i.nt f t
vnvn ") ;
101
/* Printing "B" matrix */
printf(HMatrix B:\n\n")j
for(j=Oij<=nij++)
{
printf(M%f\n~,b[j])
}
}
void ThomasElimination()
{
for (k = OJ k <=nik++) {
for (i = k +
i <= n : i++) {
= a[i] [k] / ark] [k] j
for (j = k + 1; j <= n; j++)
a[i] [j] = a[i] [j] - ark] [j] * a[i] [k]
b[i] = b(i] - a[i] [k] * b[k];
1j
a[i] [k]
}
}}
void AmatrixAfterElimination()
{
printf("\n")j
}
}
void BrnatrixAfterElimination()
{
102
void ProcessToGetKmatrix()
{
b en] = b [n]
/ a en] en] i
/* Thermal
~onductivity
values at deltax
void thermalconductivityvalues()
{
0.2 */
103
/**********************************************************************
***********************************************************************
SPATIALLY-DEPENDENT THERMAL CONDUCTIVITY FOR KNOWN HEATFLUX AT LEFT
BOUNDARY
X=O
(EXAMPLE: 4)
***********************************************************************
**********************************************************************/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
double
deltat */
double
int
variables
int
double
b[100] ,g[lOO] [100];
void title();
/* Title of the program */
void input () ;
/* Entering deltax, deltat and n */
void xlocations()i
/* Calculating nodal points in x-direction
i.e. X[j] */
void tlocations();
/* Calculating nodal points in t(time)-direction
i.e. t[j] */
void temperaturevalues()i
/* Calculating nodal temperature
values */
void heatgenerationvalues()i
/* Calculating nodal Heat Generation
values */
/* Calculating ItAIt and
B" matrices at
void AandBmatrices();
deltax = 0.1, deltat = 0.1
time = 0.2 which means i=2*/
void ThomasElimination();
/* Applying Thomas Elimination
Algorithm */
void AmatrixAfterElimination();
/* Matrix nA It after Elimination */
void BmatrixAfterElimination();
/* Matrix liBIt after Elimination */
void ProcessToGetKmatrix()i
/* Back substitution method to get Thermal
conductivity values at differant xlocations */
void thermalconductivityvalues()i
II
title() ;
input() ;
xlocations()i
tlocations() ;
temperaturevalues();
heatgenerationvalues();
AandBmatrices() ;
ThomasElimination() ;
104
ArnatrixAfterElimination() ;
BmatrixAfterElimination() ;
ProcessToGetKmatrix();
thermalconductivityvalues() ;
}
tl
scanf (%d
printf(lt\n\nlt)i
&n) i
printf("\n") ;
}
105
printf(Ht=\tH)i
for (i = 0; i <=ni i++) {
time-direction */
t[i] = i * deltat;
printf("\n\n") ;
}
pr i nt t t s vn ")
pr i.nt t
t vn vn ") i
v
for(j=Oij<=njj++)
locations*/
for(i=Oji<=nji++)
{
106
printf(M%8.4lf M,g[j] [i]);
locations*/
printf ( M\n
It )
}
}
void AandBmatrices()
{
printf("\n
i=2j /* at deltat = 0.1, at time = 0.2 */
/* Calculating "A" and "Bit matrices */
lt
a[O] [0]
a[O] [1]
=i
=0;
q=(-54)*exp(-t[i])j
b [0] = (q) / ( (T [1] [i] - T [0] [i]) / ( del tax) ) ;
for (j = 1; j <= n; j++) {
a[j][j - 1] = T[j - l][i] - T[j + l][i];
a[j] [j] = 4 * (T[j - 1] [i] - (2 * T[j] [i]) + T[j +
l][i]);
T [j] [i])
T[n] [i]
T[n -
1] [i])
+( 2
T[n] [i]);
j(
ben]
deltat-g[n][i]);
=(
printf(MMatrix A:\n\n");
/* Printing MAlt matrix */
for (j = OJ j <=nj j++) {
for (k = OJ k <=nj k++) {
pr i.nt t t " %8.41f
a[jJ[k]};
lt
pr Irrt f t vn") ;
s
printf("\n\n") ;
/* Printing MBM matrix */
printf(MMatrix B:\n\n
for(j=O;j<=n;j++)
lt
printf("%f\n",b[j]) ;
}
}
107
void ThomasElimination()
{
for (k
= OJ
k <=njk++) {
for (i = k + 1j i <= n; i++) {
a[i] [k] = a[i] [k] / ark] [k];
for (j = k + 1; j <= nj j++)
a[i] [j] = a[i] [j] - ark] [j] * a[i] [k];
b[i] = b[i] - a[i] [k] * b[k];
}}
void AmatrixAfterElimination()
{
printf ( - \n" ) ;
}
}
void BmatrixAfterElimination()
{
void ProcessToGetKmatrix()
{
i--)
108
add = 'b [i] ;
for (k = i + 1; k <= n j k++)
add = add - b[k] * a[i] [k]j
b [ i ] = add / a [ i] [i] ;
}
void thermalconductivityvalues()
{
0.2 */
109
/**********************************************************************
***********************************************************************
***********************************************************************
**********************************************************************/
#include<stdio.h>
#include<stdlib.h>
#include<m.ath.h>
double
deltat */
double
int
variables
/* q is a heatflux */
/* n = No. of intervals, i & j are position
title()i
input()i
xlocations();
tlocations();
temperaturevalues()i
heatgenerationvalues()i
AandBmatrices();
ThomasElimination() i
AmatrixAfterElimination()i
BmatrixAfter~limination();
ProcessToGetKmatrix() ;
110
therrnalconductivityvalues() ;
}
--------------------------");
printf(N\n\n
ll
scanf (N%d
pr i nt f t vnvn ") i
ll
&n);
x-
pr i.nt t
t vn ") ;
v
void tlocations(void)
{
printf(Nt=\t") ;
for (i = 0; i <=n; i++) {
time-direction */
111
t[i] = i * deltat;
}
printf(lI\n\n")i
}
void temperaturevalues(void)
{
printf ( " \n
II
printf (
II
vnvn
It
for(i=Oii<=nii++)
{
p r i nt.f t vn
v
112
B" matrices */
printf("\n")j
i=l; /* at deltat = 0.1 which means time = 0.2 */
/* Calculating "A" and "B" matrices */
a[O] [0] = T[2] [i] - (3 * T[l] [i]) +( 2 * T[O] [i]);
a[O] [1] = T[l] [i] - T[O] [i);
b[O] = (deltax * deltax) * (T(O] [i+1] - T[O] [i]) / (
del tat) ) -g [0] [i] ) ;
tor (j = 1; j <= n , j++) {
a[j][j - 1] = T[j - l][i] - T[j + l ] [ i ] j
a[j] [j] = 4 * (T[j - 1] [i] - (2 * T[j] [i]) + T[j +
n u n.
T [j] [i])
1]
= 0;
a en] en] = 1;
q=0.5*(1+exp(-t[i])*sin(1*exp(-t[i])*cos(1);
ben] =(q) / T[n][i] - T[n-1][i]) /( de l t ax l l .
printf("Matrix A:\n\n")i
/* Printing "A" matrix */
for (j = OJ j <=n; j++) {
for (k = 0; k <=n; k++) {
printf(" %8.4lf tl , a[j][k]);
}
printf("\n")i
}
printf("\n\n")i
/* Printing "B" matrix */
printf("Matrix B:\n\n");
for(j=Oij<=nij++)
{
printf("%f\n",b[j]);
}
}
113
void ThomasElimination()
{
for (k = 0; k <=n;k++){
for (i = k + 1; i <= n; i++) {
a[i] [k] = a[i] [k] / ark] [k];
for (j = k + 1; j <= ni j++)
a[i] [j] = a[i] [j] - ark] [j] * a[i] [k];
b[i] = b[i] - a(i] (k] * b[k] i
}
}}
void ArnatrixAfterElimination()
{
II
printf(M\n")
}
}
void BmatrixAfterElimination()
{
void ProcessToGetKmatrix()
{
b[n]
114
add = b [i] ;
for (k = i + 1; k <= n; k++)
add = add - b[k] * a[i] [k];
b [ i ] = add / a [ i] [i] ;
}
}
void thermalconductivityvalues()
{
115
/***********************************************************
************************************************************
Program: This is the ANALYTICAL SOLUTION based on
Inverse Heat Conduction for III posed problems text book[ll]
************************************************************
************************************************************/
/* Header files */
#include<stdio.h>
#include<math.h>
#define tol 0.000001
/* Tolerence */
/* Global Variables */
double t,x,tplus,xplus,sum,sum1,series;
int n,tsteps,xsteps,i,ji
double l,qc,alpha,lengthi
double deltat,deltaxi
double TO,k/temperature;
main()
{
/******************************************************
*******************************************************
INPUT DATA
********************************************************
********************************************************/
/* No. of Time Steps */
printf(Nplease enter No. of tsteps:)i
scanf('d,&tsteps)i
/* Time Interval */
printf(Mplease enter deltat:
scanf ("%lf &deltat) ;
ll
/* space interval */
printf("please enter deltax:);
scanf(N%lfN,&deltax)i
/* Length of the beam */
lengtb=O.Ol;
/* Heat Flux */
qc=-200000.0;
/* Alpha */
alpha=O.OOSS22;
/* Thermal Conductivity */
k=20.0;
/* Initial temperature */
116
TO=400.0;
/* Location */
xplus=deltax/lengthi
/* Specific time */
tplus=(alpha*deltat)/(length*length)i
printf("\n\n)i
printf(\t\t\tx+=%lf\n\n,xplus)i
printf("t+\t\t
T+\t\tTemperature\n\n") i
/* Main Loop */
for(i=lii<=tstep sii++)
{
suml=O.Oi
n=l;
while(n<10000){
t=i*tpluSi
x=xplus;
sum=t+(1.O/3.0)-x+((O.5)*x*x) i
1 = (double) ni
series=(-2.0/(M_PI*M_PI))*(1.O/(1*1))*exp((l*l*M_PI*M_PI*t))*cos(l*M_PI*x)i
suml=suml+series;
if(_ABS(series)<=tol)
/* check */
break;
else
n++;
}
surn=sum+suml i
temperature=TO+sum*(qc*length/k);
/******************************************************
*******************************************************
OUTPUT DATA
********************************************************
********************************************************/
/* Printing Result */
printf(M%lf\t %If\t %If\n",t,sum,temperature)i
}
}
117
/**********************************************************************
***********************************************************************
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
/* Global Variables */
double
deltax, deltat, cp, row, d, add;
daub I e
x [ 500], t [ 2500], T [2500] (500], q [ 500] [2500] ,
k[2S00] [500] ,
kl [2500] [500], Tl [250 0] [500] i
a[SOO] [500], b[500], bi [500], b2 [500] ;
double
In,n, m, check,xyzj
int
s;
int
/* Function Prototypes */
input();
/* Input data */
void
xvalues();
/* Calculating space values */
void
tvalues()i
/* Calculating time values */
void
heatflux()j /* Function for Heat flus */
void
initialtemperature(); /* Function for Initial
void
Temperature */
test();
void
aandbmatrix()j /* Forming A and B matrix */
void
guass(); /* Applying Gauss Elimination */
void
void
loop(); /* Loop process */
thermal(); /* Finding temperature */
void
tt ( ) ;
void
static int maxiter = 0;
118
/*************************************************************
**************************************************************
MAIN
DESCRIPTIN : It calls all the functions the and finds the results.
Here tirne(xyz) is zero at first and then it goes into loop
computing temperature at fixed space after one
time step. This process continues until number of
time steps reaches m.
**************************************************************
*************************************************************/
main ()
{
int
iter;
xyz=O i .
input(); /* Input asking from user */
xvalues()i /* Calculatig space
valus */
tvalues()i /* Calculatig time valus */
heatflux()i /* Calculating Heat Flux */
initialtemperature(); /* Initial Temperature */
test()i /* Themal Conductivity */
for (XYZ=OiXYZ<ffiiXYZ++)
{
aandbrnatrix(xyz)i
guass()i
Loop t j ,
maxiter = 0;
}
}
/*************************************************************
**************************************************************
INPUT DATA
**************************************************************
*************************************************************/
void
input ()
{
/****************************************************
119
**********************~******************************
SPACE VALUES
DESCRIPTTION: The complete beam is divided into
Number of space steps(n). Then it
Calculates x value at each node.
*****************************************************
****************************************************/
void
xvalues ()
{
int
ji
for (j = 1; j <= n; j++) {
x[j] = j * deltax;
}
}
/****************************************************
*****************************************************
TIME VALUES
DESCRIPTTION: Each x value subjected to Number of time
steps(m). Then it calculates t value.
*****************************************************
************~***************************************/
void
tvalues ()
{
int
ji
for (j = 0; j <= m, j++) {
t[j] = j * deltatj
}
}
/****************************************************
*****************************************************
HEAT FLUX
void
heatflux ()
{
int
j;
for (j = 0; j <= In; j++) {
q[n] [j] =483.939- (332 .324*t [j])(456.814*t[j]*t[j])+(179.939*t[j]*t[j]*t[j])( 22 . 73 6 *pow ( t [ j ] , 4) ) + ( 0 . 958 *pow ( t [ j ] , 5) ) ;
}
}
/****************************************************
120
*****************************************************
INITIAL TEMPERATURE
DESCRIPTION: This is function of space at time = O.
*****************************************************
****************************************************/
void
initialtemperature()
{
int
ji
for (j = 1 i j <= n , j ++) {
T[j] [0] = 400.0i
}
}
void
test( )
{
int
j, ii
for (j = 1i j <= n , j++) {
k[xyz] [j] =20.0;/*-4E-11*pow(T[j] [xyz],4)+7E08*pow(T[j] (xyz] ,3)-3E-05*pow(T(j] [xyz] ,2)+0.0102*T[j] [xyz]+16.226;*/
}
T [ 0] [xyz]
= T [2] [xyz] i
121
/****************************************************
*****************************************************
A and B Matrices
DESCRIPTION : Crank Nikholsen method used to find
A and B matrices.
*****************************************************
****************************************************/
void
aandbmatrix ( )
{
int
j, i;
row =7817.0; /* Row */
cp
= 0.46; /*cp */
= (deltat) / (2.0
j
OJ
a[j] [j] = 1;
a[j] [j + 2] = -1;
b[j]
a [j ] [j + 1] = -d * k1 [xyz] [j ] ;
b [ j]
d * k1 [xyz] [j - 1 ] * T [ j - 1] [xyz] + (1 - d *
(k1 [xyz] [j] + k1 [xyz] [j - 1])) * T [ j] [xyz] + d * k1 [xyz] [j] * T [ j
1] [xyz] ;
j = n + 1;
a[j] [j] = 1.0;
a[j] [j - 2] = -1.0;
a[j] [j - 1]
0.0;
b[j]
= 2.0 *
deltax
/****************************************************
*****************************************************
void
guass ()
{
int
i, j, k, p, max;
double
large, temp, ramp;
for (i = 0; i <= n + 1; i++) {
max = i;
large = a [ i] [i] ;
for (p = 0; P <= n + 1; p++)
if (a[p + 1] [i] > large) {
max = p + 1;
122
large = a[p + 1] [i];
} else {
max = max;
large = large;
}
}
ramp = b [i] ;
b(i] = b[max];
b [max] = ramp;
for (j
= 1; j <= n; j ++)
temp = a [i] [j] ;
a[i] [j]
= a[max]
[j] ;
= a[i]
[k]
/ ark] [k] ;
= b [i] ;
a[i] (k];
123
/****************************************************
*****************************************************
LOOP
DESCRIPTION: Thermal conductivity is a function of Temperature.
unknown. So assume thermal conductivity at unknown temperature is
equal to thermal conductivity at previous temperature. And then
temperature will be calculated in loop.
*****************************************************
****************************************************/
void loop ()
{
int i,ji
int yes = OJ
for(i=Oii<=n+lii++)
{
yes = 1;
breaki
}
}
rnaxiter++i
for(i=Oii<=n+lii++)
{
bl [i] = b[i];
}
thermal () i
aandbmatrix ()
guass() i
loop () ;
else{
i =99;
/* calculation at n =i */
printf("%lf\t%lf\n
U,t[xyz+1]
tt () ;
}
,b[i]);
124
/****************************************************
*****************************************************
AFTER EACH TIME STEP
DESCRIPTION: After each time step the calculated
temperature becomes the intial one.
****************************************************
****************************************************/
void tt(){
int i;
for (i = 0; i <= n + 1; i++)
In=xyz+li
T [ i] [In] =b [i] ;
k [In] [i] =k [xyz] [i] ;
for (i = 0; i <=
kl [In] [i] =kl [xyz] [i] i
ni
i++) {
}
}
/****************************************************
*****************************************************
THERMAL
DESCRIPTION: The loop process continues at the same
temperature after some iterations.
So for each iteration, after temperature
and thermal conductivity will be
calculated by using this function.
****************************************************
****************************************************/
void
thermal ()
{
int
ii
for (i = 0; i <= n+1i i++) {
b2[i] = (bl[i] + b1[i + 1]) /2.0;
}
125
/*****************************************************************
******************************************************************
PROGRAM : MINIMIZATION
DESCRIPTION : This program is used to find temperature function
using Minimization approach.
*****************************************************************
******************************************************************/
/* Header Files */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
/* Globals */
-fabs(a
float ax,XX,CXi
float time[100] ,temp[100Ji
float xl[lOOJi
int nun,ndpi .
float dff[lOO]i
float freti
float xmini
/* Prototypes */
void dfpmin(float p[],int , int );
float func(float prj);
void dfunc(float p[],float dff[])i
void linmin(float p[],float xi[],int )i
void mnbrak(float ,float ,float,float pcom[],float xicom[])i
float fldim(float x,float p[],float Xi[])i
float FMAX(float c,float d)i
float dbrent(float pcom[],float xicom[]);
float dfldim(float x, float pcom[], float xicom[])i
main()
{
int ii
int iteri
/****************~*********************************************
***************************************************************
INPUT
***************************************************************
***************************************************************/
printf(\nNo of Unknowns:N)i
scanf(N%dN,&nun)i
printf(N\nNo of datapoints:N)i
scanf{M%dM,&ndp)i
126
for(i=l;i<=ndp;i++)
{
printf(M\nEnter time[%d] :",i);
scanf(M%f,&time[i]);
printf(\nEnter temp [%d] :",i);
scanf(%f,&temp(i]);
}
printf("\n:INTIAL guess:\n")
for(i=l;i<=nun;i++)
{
printf(\n UN KNOWNX[%d]=",i);
scanf(%f,&xl[i]);
}
dfpmin(xl,nun,iter);
/*Printing number of iterations*/
printf(Total iterations: %d\n,iter);
i=l;
printf("Unknown[%d]=%f\n"/i /xl[l]) ;
i=2;
printf("Unknown[%d]=%f\n"/i /xl[2]) ;
}
/********************************************
*********************************************
dfpmin
DESCRIPTION:
The dfpmin function is used to find the location of
minimum and the minimum value of the function.
This is the main function which calls other function
linmin to perform the above task.It calls func
and dfunc to get the temperature function and to
calculate dff w.r.t constants. Then it calls the
linmin() to find the minimum.
Given a starting point p[l ... n] that is a vector of
length n, the Broyden Flether-Goldfarb-Shanno varient
of Davidon-Fletcher-Powell minimization is performed
on a function func(), using its gradient as calculated
by a routine dfunc(). The convergence requirement on
zeroing the gradient is input as ftol. Returned
quantities are p[l ... n] ( the location of the minimum)
iter (the number of iterations that were performed)
and fret (the minimum value of the function) .
The routine linmin() is called to perform approximate
line minimizations.)
I
********************************************
*******************************************/
127
#define nmax SO
#define itmax 2000
#define eps 1.0e-10
float hessin[nmax) [nmax),xi[nmax],g[nmax],dg[nmax];
float hdg [nmax] j
float fp;
int i,j:
int its:
float fac,fad,faej
/* p is a array of unknown constants is the same as
xl as mentioned in main */
/* Calling function func */
fp=func (p) j
/* Calculate starting gradient value*/
dfunc{p,dff) j
/*Initialize the inverse Hessian to the unit rnatrix*/
for{i=l;i<=nun;i++)
{
for{j=ljj<=nUnjj++)
{
iter=itsj
/* The new function evalution occurs in linmin{)j
save the function value fp for the next line search.
It is usually safe to ignore the value of check */
linmin{p,xi,nun);
if{2.*fabs{fret-fp)<=ftol*(fabs{fret)+fabs(fp)+eps))
return:
fp=fret:
/* save the old gradient */
for(i=l:i<=nun;i++)
{
dg[i]=g[i];
}
fret=func (p) :
dfunc{p,g) i
/* Get the new gradient */
/* Compute difference of gradients,and difference times
128
current matrix */ .
for(i=lji<=nunji++)
{
dg[i]=g[il-dg[il;
}
for(i=l;i<=nunji++)
{
hdg[il=O.;
for(j=l;j<=nunjj++)
{
hdg[il=hdg[i]+hessin(i] [jl*dg[jlj
}
}
fac=fac+dg[il*xi[ilj
fae=fae+dg[iJ*hdg[i] ;
}
dg[il=fac*xi[i]-fad*hdg[ilj
}
for(j=l;j<=nunjj++)
{
xi[i]=O.i
for(j=ljj<=nunjj++)
{
return;
}
129
/**************************************************
FUNC
DESCRIPTION:
The function func() finds the function value
p is a array of unknown constants
same as xl as mentioned in main
***************************************************/
float func(float pc])
{
float a,b,gl[lOO],funcli
float f[lOO]i
int ii
/* Assigning p values to a,b ... */
/* gl is a array of analytical function values*/
a=p [1] i
b=p [2] ;
/* Finding analytical function gl values using
Initial guess */
for(i=lii<=ndpii++)
gl[i]=a+b*time[i]i
/* initialize function f to zero */
for(i=l;i<=ndpii++)
f[i]=O.Oi
/* calculating f */
for(i=l;i<=ndpii++)
f[il=(temp[i]-gl[i])*(temp[i]-gl[i]);
/* Calculating func */
funcl=O.O;
for(i=lii<=ndpii++)
funcl=funcl+f[i];
return funcl
}
130
/*******************************************
********************************************
DFUNC
DESCRIPTION:
float a,b,gl[lOO]i
int ii
/* Assigning array p to a,b ... */
a=p [1] ;
b=p [2] i
/* Calculating analytical function gl */
for(i=l;i<=ndpii++)
gl[i]=a+b*time[i];
/* Initialize derivative of analytical function
w.r.t all constants equal to zero */
for(i=l;i<=nun;i++)
dff[i]=O.i
/* Calculation of derivatives w.r.t unknown constants */
for(i=l;i<=ndpii++)
{
dff[1]=dff[1]-2.*(temp[i]-gl[i]) ;
dff[2]=dff[2]-2.*(temp[i]-gl[i])*time[i];
}
}
/*******************************************
********************************************
LINMIN
DESCRIPTION:
131
#define nrnax 50
#define tol 1.e-10
float pcom[nrnax] ,xicom[nmax]
int ncom;
float fa,fb,fx;
int j;
ncom=nuni
for(j=l;j<=nun;j++)
{
pcom[j] =p [j] ;
xicom[j]=xi[j];
}
ax=O. ;
xx=l.;
/* Calling mnbrak function */
mnbrak(fa,fx,fb,pcom,xicom) i
/* Calling dbrent function */
fret=dbrent(pcom,xicom) i
printf("fret=%5.20lf\n",fret);
printf("xmin=%5.20lf\n",xmin);
/*
return;
}
/*******************************************
********************************************
MNBRAK
DESCRIPTION:
Given a function func, and given distinct initial
points ax, and bx, this subroutine searches in the
downhill direction and returns new points,ax, bx,cx
that bracket a minimum of the function. Also returned
are the function values at the three points fa, fb and fc.
*******************************************
*******************************************/
132
fb= fldim(xx,pcom,xicorn);
/* switch roles of a and b so that we can go downhill
in the direction from ax to xx */
if(fb>fa){
dum=ax;
axexx,
xx=dum;
dum=fb;
fb=fa;
fa=dum;
}
if(fb>=fc){
r=(xx-ax)*(fb-fc);
q=(xx-cx)*(fb-fa)i
u=xx-xx-cx)*q-(xx-ax)*r)/(2.*sign(FMAX(fabs(q-r) ,tiny) ,q-ri
ulim=xx+glimit*(cx-xx);
/* We won't go farther than this. Test various possibilities
Parabolic u is between xx and cx : try it. */
ifxx-u)*(u-exO.){
fu=fldim(u,pcom,xieom) ;
/* Got a minimum between xx and ex */
if(fu<fe){
ax=XXi
fa=fbj
xxeu ,
fb=fuj
return;
}
else ifcx-u)*(u-ulimO.){
fU=fldim(u,pcom,xicom)i
if(fu<fc){
xx=cx;
cx=u;
u=cx+gold*(cx-xx) ;
133
fb=fcj
fc=fuj
fu=fldirn(u,pcom,xicom)
}
}
else if((u-ulim)*(ulirn-cx=O.){
ueu l drnr
fu=fldim(u,pcom,xicom) i
}
axexx:
XX=CXj
CX=Ui
fa=fbi
fb=fcj
fc=fuj
}
return;
}
/*****************************************
******************************************
F1DIM
******************************************
*****************************************/
float fldim(float x,float p[],float xi[])
{
#define nmax SO
float ncom,pcom[nmax],xicom[nmax]j
float xt [nmax] i
float fldimlj
int ji
ncom=nunj
for(j=ljj<=ncomij++)
{
pcom [j ] =p [j ] ;
xicom[j] =xi [j]
for(j=lij<=ncomij++)
{
xt[j]=pcorn[j]+x*xicom[j]i
}
fldiml=func(xt)
return fldiml;
}
134
/*******************************************
********************************************
FMAX
*******************************************
******************************************/
float FMAX(float c,float d)
{
if(c>=d)
return Ci
else
return di
}
/************************************************************
*************************************************************
DBRENT
DESCRIPTION:
Given a function f and its derivative function df,
and given a bracketing triplet of abscissas ax,
bx, cx [such that bx is between ax and cx, and f(bx)
is less than both f(ax) and f(cx) ], this routine
isolates the minimum to a fractional precision of about
tol using a modification of Brent's method that uses
derivatives.The abscissa of the minimum is returned
as xmin, and the minimum function value is returned
as fx, the returned function value.
***************************************************************
***************************************************************/
float dbrent(float pcom[],float xicorn[])
{
#define ITMAX 30000
#define zeps 1.0e-5
int iter,ok1,ok2;
float a,b,d,d1,d2,du,dv,dw,dx,e=0.0;
float fu,fv,fw,fx,olde,toll,to12,u,ul,u2,v,w,x,xmi
a=(ax<cx ? ax:CX)i
b=(ax>cx ? ax:CX)i
/* ax and bx must be in ascending order, but input
abscissas need not be */
V=XXi
W=Vi
x=v;
fx=f1dim(x,pcom,xicom) ;
/* Initializations
*/
fv=fxi
fw=fxj
dx=df1dim(x,pcom,xicom)i
dV=~j
~=~;
135
xm=O. 5* (a+b) i
toll=ftol*fabs(x)+zepsi
toI2=2.0*tolli
/* Test for done here */
if(fabs(x-xm)<=(toI2-0.5*(b-a){
xmin=xj
return fXj
}
else {
136
d=O.5*(e=(dx>=O.O ? a-x
b-x))j
}
}
else{
d=O.5*(e=(dx>=O.O ? a-x
b-x))j
}
}
else{
d=O.5*(e=(dx>=O.O ? a-x
b-X))i
if(fabs(d=toll){
U=X+di
.
fu=fldim(u,pcom,xicom)i
}
else{
u=x+sign(toll,d)i
fu=fldim(u,pcom,xicom)i
/* If the minimum step in the downhill direction takes
us uphill, then we are done */
if(fu>fx)
{
xmin=x;
return fXi
}
}
else
b=Xi
V=Wj
fv=fWj
dv=dwi.
W=Xi
fw=fxi
dW=d.xi
X=Uj
fx=fui
dxedu :
xmin
=Xi
else
{
if(u<x)
a=Ui
else
b=uj
if(fu<=fw I I w==x) {
v=w;
fv=fw;
dv=dwi
137
w=Uj
fw=fuj
dw=duj
}
II
v==x
II
v==w) {
}
}
}
/******************************************************
*******************************************************
DFIDIM
*******************************************************
******************************************************/
float xt[lOO],df[lOO]j
int j;
float dfldiml;
for(j=l;j<=nun;j++)
{
xt[j]=pcom[j]+x*xicom[j]j
dfunc(xt,df) j
dfldiml=O.j
for(j=l;j<=nunjj++)
{
dfldiml=dfldiml+df[j]*xicom[j]j
}
return dfldimlj
}
138
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
dimension xl (50)
common/coml/texp(lOO),time(lOO),nun,ndp
xl is array of unknown constants
time is array of time steps
texp is array of temperature (experimental)
values corresponding time
nun is number of unknowns
ndp is"number of data points
open(1,file='inf2.dat' ,status='old')
Data file consists of time and texp values
pi=acos(-l.)
Mathematical constant PI
c
c
c
c
c
c
c
ftol=1.Oe-10
Assuming tolerence as above
Initializing nun and ndp
nun=2
ndp=lO
Reading and writing time and texp from data file
do i=l,ndp
read(l,*) time(i) ,texp(i)
write(6,*) 'time=', time(i)
write(6,*) 'temp=', texp(i)
end do
139
c
c
x1(1)=0.
x1(2)=-0.
Calling dfpmin function
call dfpmin(x1,nun,ftol,iter,fret)
Printing number of iterations
c
c
c
121
format(/)
write(6,*) 'no iter = ' ,iter
c
101
c
continue
write(6,121)
write(6,121)
Printing final values of constants
write(6,*) 'A1 = ',x1(1)
write(6,*)'Bl = ',x1(2)
c
write(6,121)
c
102
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
stop
end
****************************************************
DFPMIN
****************************************************
c
parameter (nmax=50,itmax=2000,eps=1.0e-10)
c
140
c
c
c
c
c
c
c
c
c
c
12
13
11
c
c
c
c
fret=func(p)
call dfunc(p,g)
Get the new gradient
c
c
c
c
14
15
do 16 i=l,n
hdg(i)=O.
do 15 j=l,n
hdg(i)=hdg(i)+hessin(i,j)*dg(j)
continue
141
16
c
c
continue
17
18
19
21
c
c
c
c
c
c
c
c
22
23
c
24
continue
c
return
end
c
c
c
c
c
c
c
*************************************************
FUNe()
*************************************************
The function func() finds the function value
FUNC:
function func(x)
c
dimension x(SO) ,f(100) ,gl(100)
c
c
c
common/com1/texp(100),time(100) ,nun,ndp
x is a array of unknown constants
same as xl as mentioned main
142
c
c
c
c
c
101
c
c
calculating f
do i=l,ndp
f(i)=(texp(i)-gl(i)*(texp(i)-gl(i
end do
Calculating func
func=O.
do j=l,ndp
func=func+f(j)
end do
return
end
c
c
c
c
c
c
c
**************************************************
DFUNC ()
**************************************************
Calculates the gradiant value of the function
DFUNC:
subroutine dfunc(x,dff)
c
c
c
c
c
c
c
c
c
dimension gl(100)
dimension x(SO),dff(SO)
common/com1/texp(lOO),time(lOO),nun,ndp
gl is a array of analytical function
x is a array of unknown constants same as xl
in main
nun is number of unknowns
ndp is number of data points
Assigning array x to a,b ...
a=x (1)
b=x(2)
Calculating analytical function gl
do i=l,ndp
143
gl(i)=a+b*time(i)
end do
c
c
c
c
c
c
c
do i=l,nun
dff(i)=O.
end do
Calculation of derivatives w.r.t unknown constants
do i=l,ndp
dff(1)=dff(1)-2.*(texp(i)-gl(i
dff(2)=dff(2)-2.*(texp(i)-gl(i*time(i)
end do
c
return
end
c
c
*************************************************
LINMIN()
c
c
c
c
c
c
c
c
c
c
*************************************************
Given an n-dimensional point p[l .. n] and an n-dimensional
direction xi[l ... nl, moves and resets p to where
the function func(p) takes on a minimum along the
direction xi and p and replaces xi by the actual vector
displacement that p was moved. Also returns as fret the
value of func at the returned location p.This is actually
accomplished by calling the routines mnbrak and brent.
LINMIN:
c
subrou~ine
linmin(p,xi,n,fret)
parameter (nrnax=50,tol=1.e-10)
external fldim,dfldim
dimension p(SO),xi(SO)
11
c
c
cornmon/flcom/ncom,pcom(nrnax) ,xicom(nrnax)
ncom=n
do 11 j=l,n
pcom(j)=p(j)
xicom(j)=xi(j)
continue
Initial guess for brackets
ax=O.
xx=l.
Calling mnbrak function
call mnbrak(ax,xx,bx,fa,fx,fb,fldim)
144
c
c
12
write(6,*) 'xmin=',xmin
Calling dbrent function
fret=dbrent(ax,xx,bx,ftol,xmin)
write(6,*) 'fret=' ,fret
Construct the vector results to return
do 12 j=l,n
xi(j)=xmin*xi(j)
p (j ) =p (j ) +xi (j )
continue
return
end
c
c
c
****************************************************
****************************************************
F1DIM( )
11
c
c
function f1dim(x)
parameter (nmax=50)
common/f1com/ncom,pcom(nrnax) ,xicom(nrnax)
dimension xt(nrnax)
do 11 j=l,ncom
xt(j)=pcom(j)+x*xicom(j)
continue
f1dim=tunc(xt)
return
end
****************************************************
DF1DIM( )
**************************~*************************
11
12
c
c
c
function df1dim(x)
parameter (nmax=50)
common/flcom/ncorn,pcom(nrnax) ,xicom(nmax)
dimension xt(nrnax),df(nrnax)
do 11 j=l,ncom
xt(j)=pcom(j)+x*xicom(j)
continue
call dfunc(xt,df)
dfldim=O.
do 12 j=l,ncom
dfldim=df1dim+df(j)*xicom(j)
continue
return
end
****************************************************
c
c
c
c
c
MNBRAK( )
****************************************************
MNBRAK
145
c
c
subroutine mnbrak(ax,bx,cx,fa,fb,fc,fldim)
c
parameter(gold=1.618034,glimit=lOO.,tiny=1.e-20)
external fldim
c
c
c
c
c
c
1
c
c
e
fa=fldim(ax)
fb=fldim(bx)
SWitch roles of a and b so that we can go downhill
in the direction from ax to bx
if(fb.gt.fa) then
dum =ax
ax=bx
bx=dum
dum=fb
fb=fa
fa=dum
endif
First guess for cx
cx=bx+gold*(bx-ax}
fc=fldim(cx)
Keep returning here until we bracket
Compute u by parabolic extrapolation from ax,bx,cx.
tiny is used to prevent any possible division by zero.
if(fb.ge.fe) then
r=(bx-ax)*(fb-fc)
q=(bx-ex) * (fb-fa)
u=bx-((bx-cx)*q-(bx-ax)*r)j(2.*sign(max(abs(q-r) ,tinY),q-r
ulim=bx+glimit*(cx-bx)
We won't go farther than this. Test various possibilities
Parabolic u is between bx and cx : try it.
ifbx-u)*(u-cx) .gt.O.) then
fu=fldim(u)
Got a minimum between bx and ex
if(fu.lt.fc) then
ax=bx
fa=fb
bx=u
fb=fu
return
Got a minimum between ax and u.
else if(fu.gt.fb) then
cx=u
fc=fu
return
endif
Parabolic fit was no use. Use default magnification
u=cx+gold*(cx-bx)
fu=fldim(u)
Parabolic fit is between ex and its allowed limit
146
bx=cx
cx=u
fa=fb
fb=fc
fc=fu
go to 1
endif
return
end
c
c
c
c
c
c
c
c
c
c
c
c
c
c
************************************************
DBRENT
************************************************
Given a function f and its derivative function df,
and given a bracketing triplet of abscissas ax,
bx, cx [such that bx is between ax and cx, and f(bx)
is less than both f(ax) and f(cx) ], this routine
isolates the minimum to a fractional precision of about
tol using a modification of Brent's method that uses
derivatives.The abscissa of the minimum is returned
as xmin, and the minimum function value is returned
as fx, the returned function value.
function dbrent(ax,bx,cx,tol,xmin)
pararneter(itmax=3DOOO,zeps=1.Oe-15)
external fldim,dfldim
logical okl,ok2
a=min(ax,cx)
b=max(ax,cx)
v=bx
w=v
x=v
147
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
148
endif
if(abs(d) .gt.abs(O.5*olde) go to 1
u=x+d
if(u-a.lt.toI2.or.b-u.lt.toI2) d=sign(toll,xm-x)
write(6,*) 'd=' ,d
write(6,*) 'toll=' ,toll
write(6,*) 'xm-x=' ,xm-x
go to 2
endif
if(dx.ge.O.) then
Decide which segment by the sign of the derivative
e=a-x
else
e=b-x
endif
d=O.5*e
if(abs(d) .ge.toll) then
u=x+d
fu=fld~m(u)
c
c
c
else
u=x+sign(toll,d)
fu=fldim(u)
If the minimum step in the downhill direction takes
us uphill, then we are done
if(fu.gt.fx) go to 3
endif
Now all the housekeeping, sigh
du=dfldim(u)
if(fu.le.fx) then
if(u.ge.x) then
a=x
else
b=x
endif
V=W
fv=fw
dv=dw
w=x
fw=fx
dw=dx
x=u
fx=fu
dx=du .
else
if (u . 1 t . x) then
a=u
else
b=u
endif
if(fu.le.fw .or. w.eq.x) then
v=w
fv=fw
dv=dw
149
11
3
w=u
fw=fu
dw=du
else if(fu.le.fv .or. v.eq.x .or. v.eq.w) then
v=u
fv=fu
dv=du
endif
endif
continue
xmin=x
dbrent=fx
return
end
150
AW~D~B
/******************************************************************
*******************************************************************
#include<stdio.h>
/******************************************************************
Global Data
******************************************************************/
double time[12000],temp[12000];
int n j
main()
{
int i;
double sumTemp=O.Oj /* Sum of Temperatures */
double sumTime=O.Oj /* Sum of Time */
int j;
n=11000;
/* No of Data Points */
for(i=O;i<=n;i++)
{
scanf("%lf\t%lf\n",&time[iJ,&temp[i]) ;
}
for(i=Oji<=nji++)
{
sumTemp = sumTemp+temp[i]j
sumTirne = sumTirne+time[i]j
j=(i%100);
if(j==O)
{
if(i!=O)
printf(%lf\t%lf\n",sumTime/100,sumTemp/100)i
if(i==O)
printf("%lf\t%lf\nU,sumTime,sumTemp)j
sumTemp=O.Oj
surnTime=O.Oj
}
}
}
151
/******************************************************************
******************************************************************
#include<stdio.h>
#include<matn.h>
#include<stdlib.h>
/******************************************************************
Global Data
******************************************************************/
Main Program
******************************************************************/
rnain()
{
/******************************************************************
Local Data
******************************************************************/
int i,jj
int n,mi
double l,alpha,k,p,temperaturei
double suml,sum2,sumJ,sum4,sum5,sum6,sum7,sum8i
double sum9,sumlO,sumll,sum12,sum13,sum14,sum15,sum16i
double sum17,sum18,sum19,sum20,sum21,sum22j
double sum23,sum24,sum25,sum26,sum27,sum28j
double sum29,sumJO,sum31,sumJ2,sum33,sumJ4j
double sum35,sumJ6,sumJ7,sumJ8,sum39,sum40j
/******************************************************************
alpha=O.0000039j
k=17.0j
/* Thermal Conductivity */
1=0.00635; /* Length of the beam */
n=50i
/* No. of Iterations */
m=110j
/* No. of Data Points */
nc=6j
/* No. of Coefficients */
152
/********,************~*********************************************
Input File
******************************************************************/
for(i=O;i<=m;i++){
scanf("%lf\t%lf",&t[i],&Texp[i]) ;
}
surnl=O.O;
for(i=1;i<=n;i=i+2){
suml=sum1+(1.0/pow(i,4)) ;
}
for(j=Oij<=mij++){
su.m2=O.O;
for(i=lji<=nii=i+2){
su.m2=su.m2+(((-i*i*M_PI*M_PI)+12.0)/(pow(i,4)))
*exp(-alpha*pow((i*M_PI/l) ,2)*t[j]);
}
surn3=O.O;
for(i=2;i<=nii=i+2){
sum3=surn3+((exp(-alpha*pow((i*M_PI/l),2)*t[j]))/(i*i));
}
surn4=O.Oi
for(i=1;i<=nii=i+2){
sum4=sum4+(exp(-alpha*pow((i*M_PI/l) ,2)*t[j])/(pow(i,4)));
}
sum6=O.O;
for(i=lii<=n;i=i+2){
p=alpha*pow(i*M_PI/l,2) ;
sum6=sum6+((-i*i*M_PI*M_PI+12.0)/(pow(i,4)*p)) ;
}
sum7=O.O;
for(i=2;i<=n;i=i+2){
p=alpha*pow(i*M_PI/l,2) ;
153
sum7=sum7+(1.O/(i*i*pi
}
sum8=O.O;
for(i=1;i<=n;i=i+2){
p=alpha*pow(i*M_Pljl,2);
sum8=surn8+(exp(-alpha*powi*M_PI/l) ,2)*t[j])j(-i*i*p*p;
}
sum9=O.O;
for(i=1;i<=n;i=i+2){
p=alpha*pow(i*M_Pljl,2);
sum9=surn9+(exp(-alpha*powi*M_PI/l) ,2)*t[j])
*(12.0-(i*i*M_PI*M_PI/(p*pow(i,4);
sumlO=O.O;
for(i=2;i<=n;i=i+2){
p=alpha*pow(i*M_Pljl,2);
sumlO=sumlO+(exp(-alpha*powi*M_PI/l) ,2)*t[j]j(p*pow(i,2;
}
e[l] [j]=alpha*t[j]*t[j])j(2.0*k*1+1*t[j])/(12.0*k
-(24.0*alpha}/(k*1*M_PI*M_PI*sumS)
-(2.0*1)/{k*pow(M_PI,4)*(sum6+(M_PI*M_PI*surn7)
+(24.0*alpha)/(k*1*M_PI*M_PI*sum8)
+(2.0*1)/(k*pow(M_PI,4)*(sum9+(M_PI*M_PI*sumlO};
sumll=O.O;
for(i=lii<=n;i=i+2){
p=alpha*pow(i*M_PI/l,2);
suml1=sumll+t[j]*t[j])/p)-2.0*t[j])/(p*p}}
+(2.0/(p*p*p)/(i*i;
}
sum12=O.O;
for(i=1;i<=n;i=i+2){
p=alpha*pow(i*M_PI/l,2);
sum12=sum12+(-(i*i*M_PI*M_PI)+12.0)jpow(i,4
*(2.0*t[j])/p}-(2.0/(p*p ;
sum13=O.O;
for(i=2;i<=n;i=i+2){
p=alpha*pow(i*M_PI/l,2) ;
sum13=sum13+2.0*t[j])/p)-(2.0/(p*p)*(1.O/(i*i)))
}
154
surn14=O.O;
for(i=1;i<=nii=i+2){
p=alpha*pow(i*M_PI/l,2)i
sum14=sum14+((exp(-alpha*pow((i*M_PI/l) ,2)*t[j]))
*(2.0/(i*i*pow(p,3 ;
}
surn15=O.O;
for(i=1;i<=n;i=i+2){
p=alpha*pow(i*M_PI/l,2)j
sumlS=sumlS+(-(i*i*M_PI*M_PI)+12.0)*(-2.0/(pow(i,4)*p*p))
*(exp(-alpha*powi*M_PI/l},2)*t[j]);
}
sum16=O.O;
for(i=2ji<=nji=i+2){
p=alpha*pow(i*M_PI/l,2)j
sum16=sum16+exp(-alpha*powi*M_PI/l) ,2}*t[j]
*(-2.0/(i*i*p*p) j
}
sum18=O.O;
for(i=1;i<=n;i=i+2){
p=alpha*pow(i*M_PI/l,2);
sum18=sum18+(-(i*i*M_PI*M_PI)+12.0)/pow(i,4
*(3.0*t[j]*t[j])/p)
- ( ( 6 . 0 * t [ j ] ) / (p *p) ) + ( 6 . 0/ (p *p *p) ) ) ) ;
}
sum19=O.Oj
for(i=2ji<=nii=i+2){
p=alpha*pow(i*M_PI/l,2) i
sum19=sum19+(3.0*t[j]*t[j])/p)
155
- ( (6 . 0 * t [ j ] ) / (p *p) )
+ (.( 6 . 0) / (p *p *p) ) ) * ( 1 . 0 / ( i * i) } )
sum20=O.O;
for(i=1;i<=n;i=i+2){
p=alpha*pow(i*M_PI/l,2)j
sum20=sum20+exp(-alpha*powi*M_PI/l),2)*t[j]
*(-6.0/(i*i*pow(p,4 ;
}
sum21=O.Oj
for(i=1;i<=nii=i+2){
p=alpha*pow(i*M_PI/l,2) i
sum21=sum21+(-(i*i*M_PI*M_PI)+12.0)*(6.0/(pow(i,4)*p*p*p
*(exp(-alpha*powi*M_PI/l),2)*t[j];
}
sum22=O.Oj
for(i=2ii<=nii=i+2){
p=alpha*pow(i*M_PI/l,2)i
sum22=sum22+exp(-alpha*powi*M_PI/l),2)*t[j])
* ( 6 . 0 / ( i * i *p *p *p) ) ) ;
}
sum23=O.Oj
for(i=lii<=nii=i+2) {
p=alpha*pow(i*M_PI/l,2)i
sum23=sum23+t[j]*t[j]*t[j]*t[j)/p)
- ( (4 0 * t [j ] * t [ j ] * t [j ] ) / (p *p) )
+12.0*t[j]*t[j])/(p*p*p
-24.0*t[j])/(p*p*p*p
+(24.0/pow(p,S)/(i*ii
}
sum24=O.Oj
for(i=1;i<=n;i=i+2){
p=alpha*pow(i*M_PI/l,2);
sum24=sum24+ ( ( ((i*i*M_PI*M_PI)+12.0)/pow(i,4*(4.0*t[j]*t[j]*t[j])/p)
-12.0*t[j]*t(j])/(p*p+24.0*t[j])J(p*p*p(24.0/pow(p,4 j
}
sum25=O.O;
for(i=2;i<=n;i=i+2){
156
p=alpha*pow(i*M~PI/l,2)j
sum2S=sum2S+((((4.0*t[j]*t[j]*t[j))/p)
-((12.0*t[j]*t[j])/(p*p))+((24.0*t[j])/(p*p*p))
-(24.0/pow(p,4)*(1.O/(i*i))) i
}
sum26=O.Oj
for(i=lji<=n;i=i+2){
p=alpha*pow(i*M_PI/l,2) ;
sum26=sum26+((exp(alpha*pow((i*M_PI/l),2)*t[j]*(24.0/(i*i*pow(p,S)) i
}
sum27=O.Oj
for(i=lji<=nii=i+2) {
p=alpha*pow(i*M_PI/l,2)j
sum27=sum27+(((-(i*i*M_PI*M_PI)+12.0)*(24.0/(pow(i,4)*p*p*p*p
*(exp(-alpha*pow((i*M_PI/l),2)*t[j] ;
}
sum28=O.Oj
for(i=2ji<=nji=i+2){
p=alpha*pow(i*M_PI/l,2)j
sum28=sum28+((exp(-alpha*pow((i*M_PI/l) ,2)*t[j]*(24.0/{i*i*p*p*p*p)j
}
c[4] [jl=alpha*pow(t[j],S/(S.O*k*l
+1*pow(t[j],4j(12.0*k
-24.0*alpha/{k*1*M_PI*M_PI*sum23)
-((2.0*1)/(k*pow(M_PI,4)*(sum24+(M_PI*M_PI*sum2S)
+((24.0*alpha)/(k*1*M_PI*M_PI*sum26)
+((2.0*1)/(k*pow(M_PI,4)*(sum27+(M_PI*M_PI*sum28)
sum29=O.Oj
for(i=lji<=nii=i+2){
p=alpha*pow(i*M_PI/l,2)j
sum29=sum29+(pow(t[j],S)/p)-((S.O*pow(t[j],4/(p*p
+(20.0*t[j]*t[j]*t[j])/(p*p*p((60.0*t[j]*t[j))/(p*p*p*p))
+((120.0*t[j])/pow(p,S))-(120.0/pow(p,6)))/(i*i)) ;
}
sumJO=O.Oj
for(i=lji<=nii=i+2){
p=alpha*pow(i*M_PI/l,2)i
sum30=sumJO+(((-(i*i*M_PI*M_PI)+12.0)/pow(i,4)
*((S.O*t[j]*t[j]*t[j]*t[j])/p)
-((20.0*t[j]*t[j]*t[j])/(p*p)
+(60.0*t[j]*t[j])/(p*p*p
-120.0*t[j])/pow(p,4)+(120.0/pow(p,5) i
}
157
sumJl=O.O;
for(i=2ii<=nii=i+2) {
p=alpha*pow(i*M_PI/l,2);
sum31=sumJl+S.O*t[j]*t[j)*t[j)*t[j])/p)
-20.0*t[j]*t[j)*t[j])/(p*p
+60.0*t[j]*t[j])/(p*p*p)
-120.0*t[j)/pow{p,4+(120.0/pow(p,S)*(1.O/(i*i)))
}
SumJ2=O.Oi
for(i=1;i<=nii=i+2){
p=alpha*pow(i*M_PI/l,2);
sum32=sumJ2+exp(-alpha*powi*M_PI/l) ,2)*t[j))
*(-120.0/(i*i*pow(p,6;
}
sumJ3=O.Oj
for(i=1;i<=nji=i+2){
p=alpha*pow(i*M_PI/l,2)i
sumJ3=sumJ3+(-(i*i*M_PI*M_PI)+12.0)
*(120.0/(pow(i,4)*p*p*p*p*p
*(exp(-alpha*powi*M_PI/l) ,2)*t[j));
}
SumJ4=O.Oi
for(i=2ji<=nii=i+2) {
p=alpha*pow(i*M_PI/l,2);
sumJ4=sum34+exp(-alpha*powi*M_PI/l) ,2)*t[j]
*(120.0/(i*i*p*p*p*p*p);
}
c[S) [j)=alpha*pow(t[j],6/(6.0*k*1
+1*pow(t[j),S/(12.0*k
-24.0*alpha/(k*1*M_PI*M_PI*s~9)
-(2.0*1)/(k*pow(M_PI,4)*(sumJO+(M_PI*M_PI*sum31)
+(24.0*alpha)/(k*1*M_PI*M_PI*sumJ2)
+(2.0*1)/(k*pow(M_PI,4)*(sumJ3+(M_PI*M_PI*sum34)i
SumJS=O.Oi
for(i=1;i<=n;i=i+2){
p=alpha*pow(i*M_PI/l,2)i
sum3S=sumJS+(pow(t[j],6)/p)-6.0*pow(t[j],5))/(p*p))
+30.0*pow(t[j],4/(p*p*p))
-120.0*pow(t[j],3/{p*p*p*p
+360.0*pow(t[j],2/pow(p,S
-720.0*t[j)/pow(p,6)+(720.0/pow(p,7)))/(i*i))i
}
sum36=O.O;
158
for(i=1;i<=n;i=i+2){
p=alpha*pow(i*M_PI/l,2);
surrU6=surrU6+(-(i*i*M_PI*M_PI)+12.0)!pow(i,4
* ( ( (6 . 0 *pow (t [j ] , 5) ) /p)
-({30.0*pow{t[j],4!{p*p
+120.0*pow(t[j],3/(p*p*p
-360.0*pow(t[j],2/pow(p,4
+720.0*t[j])/pow(p,S-(720.0!pow(p,6
sum37=O.O;
for(i=2;i<=n;i=i+2){
p=alpha*pow(i*M_PI/l,2) ;
surrU7=surrU7+6.0*pow{t[j],5/p)-30.0*pow(t[j],4/(p*p
+120.0*pow(t[j],3/(p*p*p
-360.0*pow(t[j],2/pow(p,4
+720.0*t[j])/pow(p,S
-(720.0/pow(p,6)*(1.O/(i*i)i
}
surrU8=O.0;
for(i=1;i<=n;i=i+2){
p=alpha*pow(i*M_PI/l,2);
surrU8=surrU8+exp(-alpha*powi*M_PI/l),2)*t[j]
*(720.0/(i*i*pow(p,7;
}
suin39=O.O;
for(i=lii<=nii=i+2} {
p=alpha*pow(i*M_PI/l,2)i
sum39=surrU9+(-(i*i*M_PI*M_PI)+12.0)*(720.0/(pow{i,4)*p*p*p*p*p*p
*(exp(-alpha*powi*M_PI/l) ,2)*t[j]
}
sum40=O.0;
for(i=2ii<=n;i=i+2){
p=alpha*pow(i*M_PI/l,2);
sum40=sum40+exp(-alpha*powi*M_PI/l) ,2)*t[j]
*(-720.0/(i*i*p*p*p*p*p*p);
}
159
for(i=Oji<=nc;i++){
for(j=Ojj<=nc;j++){
if(i==j){
a[i] [j]=O.O;
for (kk=Oikk<=mikk++){
a [ i] [j ] +=c [ i] [kk] *c [i]
[kk] ;
}
}
else{
a[i] [j]=O.O;
for (kk=O;kk<=mjkk++){
a[i] [j]+=c[i] [kk] *c[j] [kk];
}
}
}
}
for(i=O;i<=ncji++){
for (kk=Oikk<=rnjkk++) {
b[i]+=(Texp[kk]-Texp[O])*c[i] [kk];
}
}
printf(-\n\n-)i
for(j=Oij<=ncij++){
for(i=Oii<=ncji++){
pr in t f ( - %1 f \ t - a [ i] [j ] ) ;
I
printf(-\n-)
}
for{j=Ojj<=n~;j++){
printf{M%lf\n",b[j])
guass();
/* Printing analytical temperature */
pr i.nt f
t vnvn ") ;
r
for(i=O;i<=rn;i++){
temperature=Texp [0] + (b [0] *c [0] [i] ) + (b [1] *c [1] [i] )
+ (b [2] *c [2] [i] ) + (b [3 ] *c [3] [i] )
+{b[4]*c[4] [i] )+(b[S]*c[S] [i])
+ (b [6] *c [6] [i] ) ;
printf(M%lf\t%lf\n",t[i],temperature);
}
}
160
int
i, j, k, p, max;
double
add,large, temp, rampi
for (i = 0; i < nc ; i++) {
max = i;
large = a [ i) [i] ;
for (p = 0; p <= nc ; p++) {
if (a[p + 1] [i] > large) {
max = p + 1;
large = a[p + 1] [i];
} else {
max = max;
large = large;
}
ramp =
b[i] =
b[max]
for (j
b [ i] ;
b[max];
= ramp;
= 0; j <= nc , j++) {
temp = a [ i] [j ] ;
a[i] [j] = a[max] [j];
a[max] [j] = temp;
}
}
* a[i] [k] ;