Question: PDE problem by finite difference method (heat transfer)

Hi boys

Here I'm trying to solve this problem.

#A bar of 1meter of length is placed in a room at 10ºC. At a time t=0 its borders (x=0 and x=1) is placed in contact with Ice at 0ºC and then the system is kept isolated. Show the temperature profile of the bar at each time until t=0.2s#

#         Ut = Uxx
#         U(0,t)=0 e U(1,t)=0     => Boundary conditions
#         U(x,0)=10                     => Initial value

So, this is a simple Parabolic PDE problem that I've already solved by finite difference method, and plotted some results as you can see below:

The figure above shows the temperature profile of the bar as the time goes on from t=0 until t=0.2s.

But I'd like to do another kind of plot. Since this problem is unidimensional and I divided the bar in many small segments of length 0.05meters, I would like to plot the bar itself with its pieces and represent the temperature in each piece as time goes on. Like I tried to do in the figure below:

The figure above shows the variation of temperature as time goes on from t=0 to t=0.025s.

The problem with this kind of plot is that is not what I was expecting, here is the way I created the figure above:

bar[j] := seq( rectangle ( [t[j] , x[i] ], [ t[j] + 0.001 , x[i+1] ],  color = COLOR( RGB , u[i,j]/(10) , 0 , 0 )),i=1..nx-1);

 As you can see, with this command I create the bar[j] (because there are many of them, something about 80) by putting lots of small rectangles one above the other and each one with the color being represented by its temperature (u[i,j]) at that time. But the temperature scale is not the apropriated, although it represents the temperature profile quite good.

I think there must be some sort of comand or a way to create a temperature scale in colors where we specify a color to represent the hottest temperature and another to represent the coldest temperature, and based on this 2 extremes create the others between them.

In my case, I'd chose the color blue to represent the 0ºC and the red to represent the 10º.

Now, can anyone please help me to discover which comand I use to create this scale that I told? or if it does not exist, just give an idea of how to represent better the second plot.

Thanks,

Wellington Azevedo Silva Junior
Metallurgical Engineering - IFES
Brazil

Please Wait...