Sei sulla pagina 1di 20

Section 51

85-220 Analysis of Mechanical Systems


Winter 2014
Tutorial 6

1. Determine the solution of the nonlinear system of equations:


1 x/2
y e e x/2
2
9 x 2 25 y 2 255

Use the Newton-Raphson method and employ initial guesses of x = 2.5 y = 2.0
Solution:
function [f,J]=FuncJacob51(x)
% calculates the Jacobian and the function values
f(1)=x(2)-1/2*(exp(x(1)/2)+exp(-x(1)/2));
f(2)=9*x(1)^2+25*x(2)^2-255;
J(1,1)=-1/4*(exp(x(1)/2)-exp(-x(1)/2));
J(1,2)=1;
J(2,1)=18*x(1);
J(2,2)=50*x(2);

% Non-linear systems
clear,clc
x=[2.5 2];
epsilon=2e-4;
while (1)
[f,J]=FuncJacob51(x);
dx=J\f';
xnew=x-dx';
if abs(dx'./x)<epsilon
break
end
x=xnew;
end
disp('Roots='); disp(x);

% Roots=
% 3.1845 2.5591

2. The velocity u of air flowing past a flat surface is measured at several distances
y, m 0.0020 0.006 0.0100 0.0140 0.0180 0.0220 0.0260
u, m/s 0.7197 0.8490 0.904 0.9603 0.9951 1.0037 1.0382
The air flow forms the so called “boundary layer”, which is described by the following
relationship

1
( )

If velocity far away from the surface if U =1m/s, use linear regression to determine the
boundary layer thickness and the power n.

Solution:
Linearize the equation and use linear regression
( ) ( ) ( ) ( )
y=[0.0020 0.006 0.0100 0.0140 0.0180 0.0220 0.0260];
>> u=[0.7197 0.8490 0.904 0.9603 0.9951 1.0037
1.0382];
>> yn=log(y);
>> un=log(u);
>> polyfit(yn,un,1)
ans =
0.1420 0.5576
So n=0.1420 and
( ) ( )
or =0.0197m
3. You perform experiments and determine the following values of heat capacity c at
various temperatures T for a gas:
T -50 -30 0 60 90 100
c 1250 1280 1350 1480 1580 1700

Find the best fit of the experimental data with r2 = 0.999


Solution:
clear,clc 1700

x=[-50 -30 0 60 90 100] 1650


y=[1250 1280 1350 1480 1580 1700] 1600
p=polyfit(x,y,3)
y_fit=polyval(p,x) 1550

plot(x,y,'bd',x,y_fit) 1500

et=sum((y-mean(y)).^2) 1450
er=sum((y-y_fit).^2) 1400
r=(et-er)/et
1350
r2=sqrt(r)
%r2 = 0.9942 1300

1250

1200
-60 -40 -20 0 20 40 60 80 100 120 2
4. The curvature of a slender column/beam subjected to an axial load P (Figure 1) can be
modeled by:
d2y
p2 y 0 (1)
dx 2
P
where the spatial frequency, p is p 2 and E = 10 x 109 Pa is the modulus of elasticity
EI
and I = 1.25x10-4 m4 the moment of inertia of the cross section about its natural axis. The
model in Equation 1 can be converted to an eigenvalue problem by approximating the second
derivative with a central-difference approximation.

Equation 1 can be expressed as


yi 1 (2 x 2 p 2 ) yi yi 1 0

where x is the spacing between the nodes. If the


column of length L = 3 m is divided into five
segments (four interior nodes) the equations reduce
to

( )

( )

Or
| |
P
a) Find the eigenvalues and the corresponding loads P ( p 2 ) using
EI
polynomial method
P
b) Find the eigenvalues and the corresponding loads P ( p 2 ) using
EI
MATLAB eig function
Solution:

3
clear,clc
%problem 3
N=5;
E=10e9;
I=1.25e-4;
L=3;
dx=L/N;
A=[2 -1 0 0;-1 2 -1 0;0 -1 2 -1;0 0 -1 2 ]
%part a
c=poly(A);
d=roots(c)
F1=d*E*I/dx^2
% A =
%
% 2 -1 0 0
% -1 2 -1 0
% 0 -1 2 -1
% 0 0 -1 2
%
%
% d =
%
% 3.6180
% 2.6180
% 1.3820
% 0.3820
%
%
% F1 =
%
% 1.0e+007 *
%
% 1.2563
% 0.9090
% 0.4798
% 0.1326
%part b
[v,d]=eig(A)
F2=diag(d)*E*I/dx^2
% v =
%
% 0.3717 -0.6015 -0.6015 -0.3717
% 0.6015 -0.3717 0.3717 0.6015
% 0.6015 0.3717 0.3717 -0.6015
% 0.3717 0.6015 -0.6015 0.3717
%
%
% d =
%
% 0.3820 0 0 0
% 0 1.3820 0 0
% 0 0 2.6180 0
% 0 0 0 3.6180
%
%
% F2 =
%

4
% 1.0e+007 *
%
% 0.1326
% 0.4798
% 0.9090
% 1.2563

5
Section 52
85-220 Numerical Analysis of Engineering Systems
Winter 2014
Tutorial 6
1. Determine the solution of the nonlinear system of equations:
y x2 x 0.75
y 5 xy x2

Use the Newton-Raphson method and employ initial guesses of x = y = 1.2


Solution:
function [f,J]=FuncJacob(x)
% calculates the Jacobian and the function values
f(1)=-x(1)^2+x(1)+0.75-x(2);
f(2)=x(2)+5*x(1)*x(2)-x(1)^2;
J(1,1)=-2*x(1)+1;
J(1,2)=-1;
J(2,1)=5*x(2)-2*x(1);
J(2,2)=1+5*x(1);

% Non-linear systems
x(1)=1;
x(2)=1;
epsilon=2e-4;
while (1)
[f,J]=FuncJacob(x);
dx=J\f';
xnew=x-dx';
if abs(dx'./x)<epsilon
break
end
x=xnew;
end
disp('Roots='); disp(x);

% Roots=
% 1.3721 0.2395
2. Bessel functions often arise in advanced engineering analyses such as the study of
electric fields. Here are some selected values for the zero-order Bessel function of the
first kind. Use polynomial regression to determine the best fit and calculate the r2
error for each case. Estimate J1(2.1) using third- and fourth-order polynomials.

x 1.8 2.0 2.2 2.4 2.6

J1(x) 0.5815 0.5767 0.5560 0.5202 0.4708

6
Solution:
%q2 Tutorial 2
x=[1.8 2.0 2.2 2.4 2.6]
y=[0.5815 0.5767 0.5560 0.5202 0.4708]
p=polyfit(x,y,2)
y_fit=polyval(p,x)
et=sum((y-mean(y)).^2)
er=sum((y-y_fit).^2)
r=(et-er)/et
r2=sqrt(r)
J_m=polyval(p,2.1)
%second order polynomial
%p = -0.1863 0.6806 -0.0398
%r2 = 1.0000
%J(2.1) = 0.5680

3. An investigator has reported the data tabulated below for an experiment to determine
the growth rate of bacteria k (per d), as a function of oxygen concentration c (mg/L).
It is known that such data can be modeled by the following equation:

k max c 2
k
cS c 2
Use linear regression to estimate cs and kmax and predict the growth rate at c = 2 mg/L.

c 0.5 0.8 1.5 2.5 4

k 1.1 2.4 5.3 7.6 8.9

Solution: c=[0.5 0.8 1.5 2.5 4] 9


k=[1.1 2.4 5.3 7.6 8.9]
x=1./c.^2; 8

y=1./k;
7
p=polyfit(x,y,1)
kmax=1/p(2) 6
cs=p(1)*kmax
c1=linspace(0.5,4) 5

k_fit=kmax.*c1.^2./(cs+c1.^2)
4
plot(c,k,'bd',c1,k_fit)
% Ans: 3
% kmax = 10.0607
% cs = 2.0372 2

1
0.5 1 1.5 2 2.5 3 3.5 4

4. The curvature of a slender column/beam subjected to an axial load P (Figure 1) can


be modeled by:

7
d2y
p2 y 0 (1)
dx 2
P
where the spatial frequency, p is p 2 and E = 10 x 109 Pa is the modulus of elasticity
EI
and I = 1.25x10-4 m4 the moment of inertia of the cross section about its natural axis. The
model in Equation 1 can be converted to an eigenvalue problem by approximating the second
derivative with a central-difference approximation.

Equation 1 can be expressed as


yi 1 (2 x 2 p 2 ) yi yi 1 0

where x is the spacing between the nodes. If the


column of length L = 3 m is divided into five
segments (four interior nodes) the equations reduce
to

( )

( )

Or
| |
P
c) Find the eigenvalues and the corresponding loads P ( p 2 ) using
EI
polynomial method
P
d) Find the eigenvalues and the corresponding loads P ( p 2 ) using
EI
MATLAB eig function
Solution:
clear,clc
%problem 3
N=5;
E=10e9;

8
I=1.25e-4;
L=3;
dx=L/N;
A=[2 -1 0 0;-1 2 -1 0;0 -1 2 -1;0 0 -1 2 ]
%part a
c=poly(A);
d=roots(c)
F1=d*E*I/dx^2
% A =
%
% 2 -1 0 0
% -1 2 -1 0
% 0 -1 2 -1
% 0 0 -1 2
%
%
% d =
%
% 3.6180
% 2.6180
% 1.3820
% 0.3820
%
%
% F1 =
%
% 1.0e+007 *
%
% 1.2563
% 0.9090
% 0.4798
% 0.1326
%part b
[v,d]=eig(A)
F2=diag(d)*E*I/dx^2
% v =
%
% 0.3717 -0.6015 -0.6015 -0.3717
% 0.6015 -0.3717 0.3717 0.6015
% 0.6015 0.3717 0.3717 -0.6015
% 0.3717 0.6015 -0.6015 0.3717
%
%
% d =
%
% 0.3820 0 0 0
% 0 1.3820 0 0
% 0 0 2.6180 0
% 0 0 0 3.6180
%
%
% F2 =
%
% 1.0e+007 *
%
% 0.1326
% 0.4798

9
% 0.9090
% 1.2563

10
Section 53
85-220 Analysis of Mechanical Systems
Winter 2014
Tutorial 6

1. Determine the solution of the nonlinear system of equations:


1 x/2
y e e x/2
2
9 x 2 25 y 2 255

Use the Newton-Raphson method and employ initial guesses of x = 2.5 y = 2.0
Solution:
function [f,J]=FuncJacob51(x)
% calculates the Jacobian and the function values
f(1)=x(2)-1/2*(exp(x(1)/2)+exp(-x(1)/2));
f(2)=9*x(1)^2+25*x(2)^2-255;
J(1,1)=-1/4*(exp(x(1)/2)-exp(-x(1)/2));
J(1,2)=1;
J(2,1)=18*x(1);
J(2,2)=50*x(2);

% Non-linear systems
clear,clc
x=[2.5 2];
epsilon=2e-4;
while (1)
[f,J]=FuncJacob51(x);
dx=J\f';
xnew=x-dx';
if abs(dx'./x)<epsilon
break
end
x=xnew;
end
disp('Roots='); disp(x);

% Roots=
% 3.1845 2.5591

2. The velocity u of air flowing past a flat surface is measured at several distances
y, m 0.0020 0.006 0.0100 0.0140 0.0180 0.0220 0.0260
u, m/s 0.7197 0.8490 0.904 0.9603 0.9951 1.0037 1.0382
The air flow forms the so called “boundary layer”, which is described by the following
relationship

11
( )

If velocity far away from the surface if U =1m/s, use linear regression to determine the
boundary layer thickness and the power n.

Solution:
Linearize the equation and use linear regression
( ) ( ) ( ) ( )
y=[0.0020 0.006 0.0100 0.0140 0.0180 0.0220 0.0260];
>> u=[0.7197 0.8490 0.904 0.9603 0.9951 1.0037
1.0382];
>> yn=log(y);
>> un=log(u);
>> polyfit(yn,un,1)
ans =
0.1420 0.5576
So n=0.1420 and
( ) ( )
or =0.0197m
3. You perform experiments and determine the following values of heat capacity c at
various temperatures T for a gas:
T -50 -30 0 60 90 100
c 1250 1280 1350 1480 1580 1700

Find the best fit of the experimental data with r2 = 0.999


Solution:
clear,clc 1700

x=[-50 -30 0 60 90 100] 1650


y=[1250 1280 1350 1480 1580 1700] 1600
p=polyfit(x,y,3)
y_fit=polyval(p,x) 1550

plot(x,y,'bd',x,y_fit) 1500

et=sum((y-mean(y)).^2) 1450
er=sum((y-y_fit).^2) 1400
r=(et-er)/et
1350
r2=sqrt(r)
%r2 = 0.9942 1300

1250

1200
-60 -40 -20 0 20 40 60 80 100 12
120
4. The curvature of a slender column/beam subjected to an axial load P (Figure 1) can be
modeled by:
d2y
p2 y 0 (1)
dx 2
P
where the spatial frequency, p is p 2 and E = 10 x 109 Pa is the modulus of elasticity
EI
and I = 1.25x10-4 m4 the moment of inertia of the cross section about its natural axis. The
model in Equation 1 can be converted to an eigenvalue problem by approximating the second
derivative with a central-difference approximation.

Equation 1 can be expressed as


yi 1 (2 x 2 p 2 ) yi yi 1 0

where x is the spacing between the nodes. If the


column of length L = 3 m is divided into five
segments (four interior nodes) the equations reduce
to

( )

( )

Or
| |
P
e) Find the eigenvalues and the corresponding loads P ( p 2 ) using
EI
polynomial method
P
f) Find the eigenvalues and the corresponding loads P ( p 2 ) using
EI
MATLAB eig function
Solution:

13
clear,clc
%problem 3
N=5;
E=10e9;
I=1.25e-4;
L=3;
dx=L/N;
A=[2 -1 0 0;-1 2 -1 0;0 -1 2 -1;0 0 -1 2 ]
%part a
c=poly(A);
d=roots(c)
F1=d*E*I/dx^2
% A =
%
% 2 -1 0 0
% -1 2 -1 0
% 0 -1 2 -1
% 0 0 -1 2
%
%
% d =
%
% 3.6180
% 2.6180
% 1.3820
% 0.3820
%
%
% F1 =
%
% 1.0e+007 *
%
% 1.2563
% 0.9090
% 0.4798
% 0.1326
%part b
[v,d]=eig(A)
F2=diag(d)*E*I/dx^2
% v =
%
% 0.3717 -0.6015 -0.6015 -0.3717
% 0.6015 -0.3717 0.3717 0.6015
% 0.6015 0.3717 0.3717 -0.6015
% 0.3717 0.6015 -0.6015 0.3717
%
%
% d =
%
% 0.3820 0 0 0
% 0 1.3820 0 0
% 0 0 2.6180 0
% 0 0 0 3.6180
%
%
% F2 =
%

14
% 1.0e+007 *
%
% 0.1326
% 0.4798
% 0.9090
% 1.2563

15
Section 54
85-220 Numerical Analysis of Engineering Systems
Winter 2014
Tutorial 6
1. Determine the solution of the nonlinear system of equations:
y x2 x 0.75
y 5 xy x2

Use the Newton-Raphson method and employ initial guesses of x = y = 1.2


Solution:
function [f,J]=FuncJacob(x)
% calculates the Jacobian and the function values
f(1)=-x(1)^2+x(1)+0.75-x(2);
f(2)=x(2)+5*x(1)*x(2)-x(1)^2;
J(1,1)=-2*x(1)+1;
J(1,2)=-1;
J(2,1)=5*x(2)-2*x(1);
J(2,2)=1+5*x(1);

% Non-linear systems
x(1)=1;
x(2)=1;
epsilon=2e-4;
while (1)
[f,J]=FuncJacob(x);
dx=J\f';
xnew=x-dx';
if abs(dx'./x)<epsilon
break
end
x=xnew;
end
disp('Roots='); disp(x);

% Roots=
% 1.3721 0.2395
2. Bessel functions often arise in advanced engineering analyses such as the study of
electric fields. Here are some selected values for the zero-order Bessel function of the
first kind. Use polynomial regression to determine the best fit and calculate the r2
error for each case. Estimate J1(2.1) using third- and fourth-order polynomials.

x 1.8 2.0 2.2 2.4 2.6

J1(x) 0.5815 0.5767 0.5560 0.5202 0.4708

16
Solution:
%q2 Tutorial 2
x=[1.8 2.0 2.2 2.4 2.6]
y=[0.5815 0.5767 0.5560 0.5202 0.4708]
p=polyfit(x,y,2)
y_fit=polyval(p,x)
et=sum((y-mean(y)).^2)
er=sum((y-y_fit).^2)
r=(et-er)/et
r2=sqrt(r)
J_m=polyval(p,2.1)
%second order polynomial
%p = -0.1863 0.6806 -0.0398
%r2 = 1.0000
%J(2.1) = 0.5680

3. An investigator has reported the data tabulated below for an experiment to determine
the growth rate of bacteria k (per d), as a function of oxygen concentration c (mg/L).
It is known that such data can be modeled by the following equation:

k max c 2
k
cS c 2
Use linear regression to estimate cs and kmax and predict the growth rate at c = 2 mg/L.

c 0.5 0.8 1.5 2.5 4

k 1.1 2.4 5.3 7.6 8.9

Solution: c=[0.5 0.8 1.5 2.5 4] 9


k=[1.1 2.4 5.3 7.6 8.9]
x=1./c.^2; 8

y=1./k;
7
p=polyfit(x,y,1)
kmax=1/p(2) 6
cs=p(1)*kmax
c1=linspace(0.5,4) 5

k_fit=kmax.*c1.^2./(cs+c1.^2)
4
plot(c,k,'bd',c1,k_fit)
% Ans: 3
% kmax = 10.0607
% cs = 2.0372 2

1
0.5 1 1.5 2 2.5 3 3.5 4

4. The curvature of a slender column/beam subjected to an axial load P (Figure 1) can


be modeled by:

17
d2y
p2 y 0 (1)
dx 2
P
where the spatial frequency, p is p 2 and E = 10 x 109 Pa is the modulus of elasticity
EI
and I = 1.25x10-4 m4 the moment of inertia of the cross section about its natural axis. The
model in Equation 1 can be converted to an eigenvalue problem by approximating the second
derivative with a central-difference approximation.

Equation 1 can be expressed as


yi 1 (2 x 2 p 2 ) yi yi 1 0

where x is the spacing between the nodes. If the


column of length L = 3 m is divided into five
segments (four interior nodes) the equations reduce
to

( )

( )

Or
| |
P
g) Find the eigenvalues and the corresponding loads P ( p 2 ) using
EI
polynomial method
P
h) Find the eigenvalues and the corresponding loads P ( p 2 ) using
EI
MATLAB eig function
Solution:
clear,clc
%problem 3
N=5;
E=10e9;

18
I=1.25e-4;
L=3;
dx=L/N;
A=[2 -1 0 0;-1 2 -1 0;0 -1 2 -1;0 0 -1 2 ]
%part a
c=poly(A);
d=roots(c)
F1=d*E*I/dx^2
% A =
%
% 2 -1 0 0
% -1 2 -1 0
% 0 -1 2 -1
% 0 0 -1 2
%
%
% d =
%
% 3.6180
% 2.6180
% 1.3820
% 0.3820
%
%
% F1 =
%
% 1.0e+007 *
%
% 1.2563
% 0.9090
% 0.4798
% 0.1326
%part b
[v,d]=eig(A)
F2=diag(d)*E*I/dx^2
% v =
%
% 0.3717 -0.6015 -0.6015 -0.3717
% 0.6015 -0.3717 0.3717 0.6015
% 0.6015 0.3717 0.3717 -0.6015
% 0.3717 0.6015 -0.6015 0.3717
%
%
% d =
%
% 0.3820 0 0 0
% 0 1.3820 0 0
% 0 0 2.6180 0
% 0 0 0 3.6180
%
%
% F2 =
%
% 1.0e+007 *
%
% 0.1326
% 0.4798

19
% 0.9090
% 1.2563

20

Potrebbero piacerti anche