MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

### Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

# Please help as I am struggling to solve this homework problem.

Asked by Sam on 20 Aug 2012
```An H-section copper conductor carries an overload current of 54000 A. Under steady state conditions, the surface temperature is 60°C.
```
```The dimensions of the bar are given in Figure 1 overleaf, and you are asked to use a numerical method to produce a mesh plot of the temperature distribution and a graph of the temperature distribution along the line y = 0.
```
```The electrical resistivity, ρ, of copper is 2 × 10-8 Ω m, and the thermal conductivity, κ, is 0.311 kW m-1 K-1.
```
```The governing differential equation is ∂2T + ∂2T + g = 0	(1)
∂x2	∂y2	κ where g is the (constant) generation rate of heat per unit volume:
```
```g = i2ρ	(2) and i is the current density.
```
```Using an appropriate Numerical Technique:
```
```Determine the temperature distribution to an accuracy of 4 significant figures
```
```You are expected to hand in the following by the submission date:
```
```Hints
```
```The Gauss-Seidel technique used in Tutorial 9 can be adapted to the present problem by including the additional term g/κ in the finite difference equation. You can generate a mask array as in Tutorial 9 to specify the region of the array covered by the H cross- section.
```
```Try calculating the solution over a square mesh for a range of step lengths h = 5 mm, 2.5 mm, 1.25 mm...
You can if you wish make use of the symmetry of the problem and model just one quarter of the conductor. However, the boundary conditions then become more difficult to apply.
```
```The H section is of width 40mm, depth 30mm and cut outs on top and bottom of depth 10x width 20 mm
```

Any help would be most appreciated

Cheers

Sam

José-Luis on 20 Aug 2012

Who haz teh codez?

Sven on 20 Aug 2012

"You are expected to hand in the following by the submission date"

Uh oh...I think I skipped this lecture... where do we hand in your assignment?

Ryan on 20 Aug 2012

What have you tried so far, Sam?

## Products

No products are associated with this question.

Answer by Elizabeth on 21 Aug 2012

Don't know if this is any assistance to you but--Here is my code for the Gauss-Seidel iterative method:

```    function [ X, Ntot ] = gs( A, b, tol, nmax )
%GS is a function that utilizes the Gauss-Seidel iterative method in order to
%   to formulate an approximation to the linear algebra problem Ax=b
%Input
% A is an NxN nonsingular matrix
% b is an Nx1 matrix
% tol is the tolerance for convergence
% Nmax is the maximum number of iterations
%Output
% X is the Gauss-Seidel approximation to the soln of Ax=b
% Ntot is the number of iterations it took to reach convergence
%%
N=length(b) ;
p=zeros(N,1);
tol=eps;
for k=1:nmax %for each iteration
for j=1:N %to solve for the unknown variable Xj
if j==1
X(1)=(b(1)-A(1,2:N)*p(2:N))/A(1,1); %x1 in terms other variables which are unknowns
elseif j==N
X(N)=(b(N)-A(N,1:N-1)*(X(1:N-1))')/A(N,N); %xN written in terms other variables
else
X(j)=(b(j)-A(j,1:j-1)*X(1:j-1)'-A(j,j+1:N)*p(j+1:N))/A(j,j); %xj written in terms of other variables
end
end
p=X';
r=max(abs(A*p-b));
if r< tol
X=p;
Ntot=k;
disp('The problem has converged to a soln');
end
end
Ntot=k;
if k>nmax
disp('Warning: the solution did not converge.');
end
end```

Jan Simon on 21 Aug 2012

Thge convergence criterion is useless in your code, because the iteration is not stopped. A missing convergence is not detected, because for k=1:nmax will never set the value of k to nmax+1, such that the test if k>nmax will be FALSE in every case. Better:

```converged = false;
while k <= nmax
...
if r < tol
converged = true;
break;
end
end
```
Elizabeth on 21 Aug 2012

Thanks for the check.