# Fourier's Heating Law

1. Nov 15, 2015

### BOAS

Hello,

I am trying to determine the thermal conductivity of a material based on the following information.

$Q_x = - k \frac{dT}{dx}$

Temperature as a function of $x, T(x)$;

$T(0) = 15$
$T(0.1) = 10$
$T(0.2) = 5$
$T(0.3) = 3$

and finally that $Q_{x=0} = 40 \mathrm{Wm^{-2}}$

The way I am approaching this problem is to use a spline to interpolate the data, and then find the derivatives of this function. My problem is that I can't figure out how to evaluate the derivative at a given point.

For example, how do I evaluate the derivative at x = 0?

Code (Python):
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import splev, splrep

x = np.array([0, 0.1, 0.2, 0.3],dtype=float)
T = np.array([15, 10, 5, 3],dtype=float)

xnew = np.linspace(0,0.3,100)
f = splrep(x,T,s=0)

ynew = splev(xnew,f,der=0)

yder = splev(xnew,f,der=1)

plt.grid(True)
plt.plot(x,T,'x',xnew,ynew,xnew,yder)
plt.show()
plt.close()

Last edited: Nov 15, 2015
2. Nov 15, 2015

### Thomas Thelen

To make sure we are on the same page,

You want to find the thermal conductivity, k, based the one-dimensional model for isotrpoic heat flux. You are given data points which were presumably taken from evenly spaces points on the surface of the object. This can obviously be used to construct a function relating the position to temperature-to an acceptable range.

Obtaining the Temperature Function:
Quick Way:
Plot the data in excel and add a trendline. One advantage of using Excel is being able to dynamically see how the residual changes with each model.
Take the derivative of the interpolated function by hand.

Python:
Use scipy.interpolate. The first example on that page should be exactly what you are looking for.

Obtaining the Derivative
Quick Way:
Do it by hand.

Python:
Numerical Methods
Instead of explicitly taking the derivative of the equation obtained by interpolation, consider using Newton's Method or Finite Differences. scipy.optimize.newton might be worth checking out.
Symbolic:
Instead of using a numerical method you can find libraries like SymPy that allow you to do symbolic algebra. This would obvoiusly be more accurate than a numerical method but would require you learn to interface with SymPY

Putting it Together
Now that the derivative is computed, it can be substituted into the equation for 1-d heat flux. Because you know what the value of Q is at the initial point, 0, evaluate the derivative at that point.
It depends on which method you chose to obtain the derivative.
If you are choosing to do a numerical method you will be including the point of interest in the algorithm.
Code (C):

double NewtonsMethod(double x)
{
double derivative;
//algorithm here
return derivative
}

int main()
{
cout<<"The derivative at 0 is :"<<NewtonsMethod(0);
return 0;
}
If you did it symbolically, you can probably just call the function like a function. It would look something like.
Code (C):

int main()
{
vector<int> x,y;
// fill x&y
derivative=Interpolation(x,y);
cout<<"The derivative at 0 is :"<<derivative(0);
return 0;
}
Once you have the numerical value for the derivative you can solve for the thermal conductivity.

3. Nov 16, 2015

### BOAS

Hello,

thank you for your response. Lot's of useful information here.

Finite difference methods sound like a good idea, and I know how to do this. I can use the central difference formula accurate to $O(h^4)$ and the method from interp1d to evaluate the spline at the relevant positions "interp1d.__call__()" (if I use interp1d) or use splev as I am already with splrep.

Thanks again.