Solving Fourier's Law w/ Splines & Derivatives

  • Thread starter Thread starter BOAS
  • Start date Start date
  • Tags Tags
    Heating Law
Click For Summary
SUMMARY

This discussion focuses on determining the thermal conductivity of a material using Fourier's Law and spline interpolation. The user provides temperature data points and seeks to evaluate the derivative of the interpolated function at a specific point, x = 0. Key methods discussed include using Python's SciPy library for spline interpolation with splrep and splev, as well as numerical methods like Newton's Method and Finite Differences for derivative evaluation. The conversation emphasizes the importance of selecting the appropriate method for accurate thermal conductivity calculations.

PREREQUISITES
  • Understanding of Fourier's Law of heat conduction
  • Familiarity with Python programming and libraries such as NumPy and SciPy
  • Knowledge of spline interpolation techniques
  • Basic concepts of numerical differentiation methods
NEXT STEPS
  • Learn how to implement scipy.interpolate.interp1d for spline evaluation
  • Explore the use of scipy.optimize.Newton for derivative calculations
  • Study the central difference formula for numerical differentiation
  • Investigate the SymPy library for symbolic differentiation in Python
USEFUL FOR

Researchers, engineers, and students involved in thermal analysis, material science, and computational physics who are looking to apply numerical methods for heat conduction problems.

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:
Technology news 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.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 15 ·
Replies
15
Views
2K
  • · Replies 4 ·
Replies
4
Views
6K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
Replies
4
Views
5K
  • · Replies 1 ·
Replies
1
Views
3K