Solving Fourier's Law w/ Splines & Derivatives

  • Thread starter Thread starter BOAS
  • Start date Start date
  • Tags Tags
    Heating Law
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 2K views
BOAS
Messages
546
Reaction score
19
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?

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:
on Phys.org
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 http://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html. 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.
BOAS said:
For example, how do I evaluate the derivative at x = 0?
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:
double NewtonsMethod(double x)
{
double derivative;
//algorithm here
return derivative
}

int main()
{
count<<"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:
int main()
{
vector<int> x,y;
// fill x&y
derivative=Interpolation(x,y);
count<<"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.
 
Thomas Thelen said:
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 http://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html. 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:
double NewtonsMethod(double x)
{
double derivative;
//algorithm here
return derivative
}

int main()
{
count<<"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:
int main()
{
vector<int> x,y;
// fill x&y
derivative=Interpolation(x,y);
count<<"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.

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.