Prob 4.32 2D Temp Field Engineering 25

advertisement

Engineering 25

Prob 4.32

2D Temp

Field

Bruce Mayer, PE

Licensed Electrical & Mechanical Engineer

BMayer@ChabotCollege.edu

Engineering-25: Computational Methods

1

Bruce Mayer, PE

ENGR-25_Linear_Regression_Tutorial.ppt

Part a MATLAB code

% Bruce Mayer, PE * 23Aug06

% ENGR25 * Problem 4-32, Part (a)

% file = Prob4_32a_2D_Termperature_Field.m

%

% Summation is on n-ODD; make index vector over 1...19

n = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19];

%

% calc the magnitude each term of w(x,y) separately wTerm = abs((2./n).*sin(n*pi/2).*(sinh(n*pi/2)./sinh(n*pi)));

%

% scale all terms relative to the first term where n = 1

% display as COL-vector my using transpose operator (')

% use Sci-Notation format format short e disp( 'The Relative Magnitude of the First 10 terms of w(x,y):' ) disp(wTerm'/wTerm(1))

Engineering-25: Computational Methods

2

Bruce Mayer, PE

ENGR-25_Linear_Regression_Tutorial.ppt

Part b MATLAB code

% Bruce Mayer, PE * 23Aug06

% ENGR25 * Problem 4-32, Part (b)

% file = Prob4_32b_2D_Termperature_Field.m

%

% Set Constants

T_1 = 70;T_2 = 200;

W = 2;L = 2; x = L/2;y = W/2;

%

% Intialize the Sum, and Error, and counter

Sum = 0

Chg = 10 n = 1 % index m = 0 % Term counter

%

% The Loop while abs(Chg) > .01 % 0.01 = 1%

Sum_next = Sum +

(2/n)*sin(n*pi*x/L)*(sinh(n*pi*y/L)/sinh(n*pi*W/L)); if n > 1 m

Chg = ((abs(Sum_next)- abs(Sum))/abs(Sum));

ChgPct = abs(Chg*100) end

Sum = Sum_next n = n + 2; % only ODD indices m = m + 1; % count the number to terms end

%

% Calc w11 using last sucessful Sum w11 = (2/pi)*Sum;

%

% calc Tmid

Tmid = (T_2- T_1)*w11 + T_1;

%

%display results disp( 'The temperature in the middle of the plate is:' ) disp(Tmid) disp( 'The number of series terms required is:' ) disp(m)

Engineering-25: Computational Methods

3

Bruce Mayer, PE

ENGR-25_Linear_Regression_Tutorial.ppt

Download