© 2001 by CRC Press LLC
{30, 13, 5, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{40, 18, 7, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{50, 20, 8, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{17, 11, 5, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 6, 5, 3, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}
Notice that In[2] initializes the boundary temperatures, nr keeps the count of
how many sweeps have been performed, and the function Round is employed in
In[4] to round the temperature value to a two-digit integer. When the total temper-
ature differences, d, is limited to eps = 100 degrees, the t values obtained after two
sweeps are slightly different from those obtained by the other versions, this is again
because Mathematica keeps more significant digits in all computation steps than
those in the FORTRAN, QuickBASIC, and MATLAB programs. By changing the
eps value from 100 degrees to 1 degree, Mathematica also takes 137 sweeps to
converge as in the FORTRAN, QuickBASIC, and MATLAB versions:
In[5]: = t = Table[0,{10},{20}]; eps = 1; nr = 0; d = eps + 1;
In[6]: = Do[t[[i,1]] = (I–1)*10,{i,2,6}];
In[7]: = Print[“Sweep #”,nr]; Round[N[t,2]]
Out[7] = Sweep #137
{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{10, 8, 7, 5, 4, 3, 3, 2, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0},
{20, 16, 13, 10, 8, 7, 5, 4, 3, 3, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0},
{30, 24, 19, 15, 12, 9, 8, 6, 5, 4, 3, 3, 2, 2, 1, 1, 1, 1, 0, 0},
{40, 30, 23, 18, 15, 12, 10, 8, 6, 5, 4, 4, 3, 2, 2, 1, 1, 1, 0, 0},
{50, 34, 26, 20, 16, 13, 11, 9, 7, 6, 5, 4, 3, 3, 2, 2, 1, 1, 0, 0},
{35, 30, 25, 21, 17, 15, 12, 10, 8, 7, 6, 5, 4, 3, 3, 2, 2, 1, 1, 0},
{29, 27, 24, 21, 18, 15, 13, 11, 9, 7, 6, 5, 4, 3, 3, 2, 2, 1, 1, 1},
{26, 26, 23, 21, 18, 16, 13, 11, 9, 8, 6, 5, 4, 4, 3, 2, 2, 1, 1, 1},
{26, 25, 23, 21, 18, 16, 13, 11, 9, 8, 7, 5, 4, 4, 3, 2, 2, 2, 1, 1}}
The above results all agree with those obtained earlier.
WARPING ANALYSIS OF A TWISTED BAR WITH NONCIRCULAR CROSS SECTION
As another example of applying the relaxation method for engineering analysis,
consider the case of a long bar of uniform rectangular cross section twisted by the
two equal torques (T) at its ends. The cross section of the twisted bar becomes
warped as shown in Figure 6. If z-axis is assigned to the longitudinal direction of
the bar, to find the amount of warping at any point (x,y) of the cross sectioned
surface, denoted as W(x,y), the relaxation method can again be employed because