how can i write a matlab code for the summation below? please help

13 views (last 30 days)
In this project, you will analyze temperature distribution , heat transfer and its relation to material properties while controlling the material hardness during a cooling process. During heat transfer process, the temperature is distributed in a flat rectangular metal plate. The temperature on three sides is held constant at T1 and at T2 on the fourth side as shown in figure below. The temperature T(x,y) as a function of xy coordinate is given by
T(x,y)=(T2-T1)w(x,y)+T1
where
w(x,y)=2/π ∑_(n odd)^[2/n sin(nπx/L)] (Sinh(nπy/L))/(Sinh(nπw/L))
The given data is as follows: T1=70̊ F, T2=200̊ F and W=L=2ft. Using a spacing of 0.2 for both x and y, generate a surface mesh plot and a contour plot of the temperature distribution.

Answers (2)

Roger Stafford
Roger Stafford on 17 Aug 2014
Edited: Roger Stafford on 17 Aug 2014
For x,y points near the edges of the plate, to preserve accuracy, it is necessary to sum the series in odd values of n up to a very high value. I chose to sum out to n = 200001, but you can adjust N according to how good your results look. The larger you make N, the more accurate the results and longer the computation takes.
Also since for large values of n the sinh function can easily overflow and produce a NaN, I have used an equivalent expression in terms of exp that will not overflow.
W = 2;
L = 2;
[X,Y] = meshgrid(0:.2:L,0:.2:W);
S = zeros(size(X));
N = 100000;
for n = 2*N+1:-2:1
S = S + 1/n*sin(n*pi*X/L).*exp(-n*pi*(W-Y)/L).*...
(1-exp(-2*n*pi*Y/L))./(1-exp(-2*n*pi*W/L));
end
T = (T2-T1)*4/pi*S+T1;
Note: This looks like homework. If so, to be fair I expect you to share these results with your classmates. But first make sure you understand it and that there are no errors in it.
  2 Comments
Star Strider
Star Strider on 17 Aug 2014
I admit to not completely understanding the problem.
Thanks for providing the correct solution.
Roger Stafford
Roger Stafford on 17 Aug 2014
@Jonathan. One additional comment. Note that the statement of the problem implies that when you are at the edge with y = W, and 0 < x < L, one ought to get a T value of T2. This in turn implies the interesting identity:
1/1*sin(1*pi*x/L)+1/3*sin(3*pi*x/L)+1/5*sin(5*pi*x/L)+... = pi/4
This is a very slowly converging series so it takes a very large number of terms to verify it, but it is in fact true that the sum of the infinite series is the constant pi/4 as long as x lies between 0 and L.

Sign in to comment.


Star Strider
Star Strider on 16 Aug 2014
I would start by defining the x and y vectors, use the meshgrid function to create the respective X and Y values for the metal plate, then evaluate it according to whatever ‘[2/n sin(nπx/L)] (Sinh(nπy/L))/(Sinh(nπw/L))’ means. (You need to clarify that.) After that, cumtrapz is probably what you want to calculate w.
  6 Comments
Star Strider
Star Strider on 16 Aug 2014
This is what I came up with independently:
W = 2; % Width
L = 2; % Length
n = 0.2; % Mesh
T1=70; % ̊ F
T2=200; % ̊ F
x = 0:0.2:2; % Width Vector (0:W)
y = 0:0.2:2; % Length Vector (0:L)
[X,Y] = meshgrid(x,y);
w = @(x,y) (2/n).*sin(n.*pi.*x./L).*sinh(n.*pi.*y./L)./sinh(n.*pi.*W./L);
T = @(x,y) (T2-T1).*w(x,y)+T1;
WP = w(X,Y);
SumX = cumtrapz(x,WP,1) * 2/pi;
SumY = cumtrapz(y,WP,2) * 2/pi;
TP = T(SumX,SumY);
figure(1)
meshc(X, Y, TP)
grid on
figure(2)
meshc(X, Y, SumX+SumY)
grid on
See if it does what you want. It’s not clear to me exactly what gets summed. I used cumtrapz rather than sum because it’s more accurate.
Roger Stafford
Roger Stafford on 17 Aug 2014
@Star Strider. It looks as though you are not summing over n in this code. As I understand the statement of the problem, a summation with respect to odd integers n is required from n = 1 to n = infinity, (though hopefully a very large number will be adequate.) Moreover no other summation is to occur.

Sign in to comment.

Categories

Find more on Mathematics in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!