Solving Fourier's Law w/ Splines & Derivatives

In summary, the conversation discusses the process of determining thermal conductivity of a material based on given information and using various methods such as spline interpolation and finite difference methods. The final step involves evaluating the derivative at a given point to obtain the thermal conductivity. Suggestions for obtaining the temperature function and the derivative are also provided. The conversation also mentions the use of tools such as Excel and libraries like SymPy for symbolic algebra.
  • #1
BOAS
552
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
  • #2
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()
{
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:
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
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()
{
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:
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.

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.
 

Related to Solving Fourier's Law w/ Splines & Derivatives

1. What is Fourier's Law?

Fourier's Law, also known as the law of heat conduction, is a fundamental principle in thermodynamics that describes how heat is transferred between two bodies in contact. It states that the rate of heat transfer is directly proportional to the temperature gradient and the surface area of the bodies, and inversely proportional to the distance between them.

2. What are splines?

Splines are mathematical functions that are used to approximate complex curves or surfaces. They are often used in data interpolation and modeling, as they are able to smoothly connect different data points without any abrupt changes or discontinuities.

3. How do splines relate to Fourier's Law?

Splines are often used to approximate the temperature profile in Fourier's Law. By fitting a spline curve to the data points of temperature and distance, we can use the derivative of this spline function to calculate the rate of heat transfer at any given point along the surface.

4. What are derivatives?

Derivatives are mathematical operations that describe the rate of change of a function with respect to one of its variables. In the context of Fourier's Law, derivatives are used to calculate the rate of heat transfer at a specific point by taking the slope of the spline curve that represents the temperature profile.

5. How does solving Fourier's Law with splines and derivatives benefit us?

Solving Fourier's Law with splines and derivatives allows us to accurately model and predict the rate of heat transfer in different systems. This can be useful in various fields such as engineering, physics, and materials science, where understanding heat transfer is crucial in designing and optimizing various processes and systems.

Similar threads

  • Programming and Computer Science
Replies
2
Views
912
  • Programming and Computer Science
Replies
15
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
3
Views
5K
  • Programming and Computer Science
Replies
4
Views
4K
  • Programming and Computer Science
Replies
3
Views
935
  • Programming and Computer Science
Replies
4
Views
4K
  • Programming and Computer Science
Replies
21
Views
4K
  • Programming and Computer Science
Replies
1
Views
949
  • Engineering and Comp Sci Homework Help
Replies
3
Views
2K
Back
Top