Вы находитесь на странице: 1из 15

Sections 51 and 54

85-220 Numerical Analysis of Engineering


Winter 2014
Tutorial 11
1. Find and plot y as function of t in the interval t=0 to 100,

with initial conditions


( )

( )

Solution:
Convert the second order equation into a system of two first order equations

with
( )
( )
An attempt to solve the system with generic methods/solvers will fail, since this is a
system of stiff ODE. Method/s for stiff ODE should be used.

[tn,yn]=ode23s(@(t,y)Prob6(t,y),[0 100],[80 1]);


plot(tn,yn(:,1))

with

function dy=Prob6(t,y)
dy(2)=-100001*y(2)-99999*y(1);
dy(1)=y(2);
dy=dy';

1
2. The temperature distribution in a tapered conical cooling fin is described by the following
nondimensional ODE.

( )( )

where u=temperature (0  u  1), x = axial distance, Bi = Biot number given by

where h=heat convection coefficient, k=heat conduction


coefficient, L=height of the cone, and m=the slope of
the cone wall. Use the shooting method to determine the
temperature distribution for various values of Bi=25, 50,
75 if the boundary values of the temperature are

( )
( )

2
Use range of integration x=0.001 to 1. Plot u(x) for each value of Bi on one plot.

Solution:
Convert the second order equation into a system of two first order equations

|
( )
with
( )
( )

Bi=[25 50 75]
T0=0;L=1; Tend=1;
dtg=fzero(@(dtg)BVPH(Tend,dtg,Bi(1)),1)
[xn1,yn1]=ode45(@(x,y)HeatCone(x,y,Bi(1)),[0.001 L],[T0,dtg]);
dtg=fzero(@(dtg)BVPH(Tend,dtg,Bi(2)),1);
[xn2,yn2]=ode45(@(x,y)HeatCone(x,y,Bi(2)),[0.001 L],[T0,dtg]);
dtg=fzero(@(dtg)BVPH(Tend,dtg,Bi(3)),1)
[xn3,yn3]=ode45(@(x,y)HeatCone(x,y,Bi(3)),[0.001 L],[T0,dtg]);
plot(xn1,yn1(:,1),xn2,yn2(:,1),xn3,yn3(:,1))
function res=BVPH(Tend,dtg,Bi)
L=1;T0=0;
[xn,yn]=ode45(@(x,y)HeatCone(x,y,Bi),[0.001 L],[T0,dtg]);
n=length(xn);
TendGuess=yn(n,1);
res=Tend-TendGuess;

with
function dy=HeatCone(x,y,Bi)
dy(1)=y(2);
dy(2)=-2/x*y(2)+2/x*y(1)*Bi;
dy=dy';

3
3. The displacement(deflection) of simply supported uniformly loaded beam is given by

where E= Young modulus, and I=moment of


inertia. The boundary conditions are
( )

|
( )

Use the shooting method to determine the


deflection, y, as function of x, if E=200GPa, I =
4
30,000cm , w = 15kN/m and L = 3m. Plot y vs x.

Solution:

Convert the second order equation into a system of two first order equations

4
|

yend= 0.2812e-3;
dtg=fzero(@(dtg)BVPBeam(yend,dtg),1);
L=3;w=15000;E=200e9;I=30000e-8;
[xn,yn]=ode45(@(x,y)BeamL(x,y,L,w,E,I),[0 L],[0,dtg]);
plot(xn,yn(:,1))
with
function res=BVPBeam(yend,dtg)
L=3;w=15000;E=200e9;I=30000e-8;
[xn,yn]=ode45(@(x,y)BeamL(x,y,L,w,E,I),[0 L],[0,dtg]);
n=length(xn);
yendGuess=yn(n,2);
res=yend-yendGuess;

function dy=BeamL(x,y,L,w,E,I)
dy(1)=y(2);
dy(2)=w*L*x/2/E/I-w*x^2/2/E/I;
dy=dy';

5
-4
x 10
0

-0.5

-1

-1.5

-2

-2.5

-3
0 0.5 1 1.5 2 2.5 3

6
Section 52
85-220 Analysis of Mechanical Systems
Winter 2014
Tutorial 11
1. Find and plot y as function of t in the interval t=0 to 100,

with initial conditions


( )

( )

Solution:
Convert the second order equation into a system of two first order equations

with
( )
( )
An attempt to solve the system with generic methods/solvers will fail, since this is a
system of stiff ODE. Method/s for stiff ODE should be used.

[tn,yn]=ode23s(@(t,y)Prob6(t,y),[0 100],[80 1]);


plot(tn,yn(:,1))

with

function dy=Prob6(t,y)
dy(2)=-100001*y(2)-99999*y(1);
dy(1)=y(2);
dy=dy';

7
2. The steady state water table height, h, in an unconfined aquifer shown in the figure
bellow can be determined by solving
dh 2
Kh  N  0,
dx 2
where x = distance (m), K = hydraulic conductivity (meters/d), h = height of water table
(m), h = average height of the water table (m), and N = infiltration rate (m/d). Use the
shooting method to solve for the height of the water table for 0m < x < 1000m, with a
boundary conditions
h(0m) = 10 m
h(1000m) = 5m.
Use the following parameters for the calculations K = 1 m/d and N = 0.0001 m/d and h
= 7.5m. Plot the h vs. x.

8
Figure: Schematic of one dimensional unconfined aquifer.

Solution:
Convert the second order equation into a system of two first order equations:
dh
w
dx
dw
Kh N 0
dx

clear,clc
k=1;h_bar=7.5;N=0.0001;
y0=10;L=1000;
dtg=0;
[tn,yn]=ode45(@(t,y)aquifer(t,y,k,h_bar,N),[0 L],[y0,dtg])
n=length(tn);
yn(n,1)
yend=5;
dtg =fzero(@(dtg)BVP(yend,dtg),1)
[tn,yn]=ode45(@(t,y)aquifer(t,y,k,h_bar,N),[0 L],[y0,dtg])
plot(tn,yn(:,1))

with functions
function dy=aquifer(t,y,k,h_bar,N)
% computes the time derivatives
dy(1)=y(2);
dy(2)=-N/k/h_bar;
dy=dy';

function res=BVP(yend,dtg)
k=1;h_bar=7.5;N=0.0001;
y0=10;L=1000;
[tn,yn]=ode45(@(t,y)aquifer(t,y,k,h_bar,N),[0 L],[y0,dtg]);
n=length(tn);

9
yendGuess=yn(n,1);
res=yend-yendGuess;

11

10

5
0 100 200 300 400 500 600 700 800 900 1000

3. The displacement(deflection) of simply supported uniformly loaded beam is given by

where E= Young modulus, and I=moment of


inertia. The boundary conditions are
( )

|
( )

Use the shooting method to determine the


deflection, y, as function of x, if E=200GPa, I =
30,000cm4, w = 15kN/m and L = 3m. Plot y vs x.

Solution:

Convert the second order equation into a system of two first order equations

10
|

yend=0.2812e-3;
dtg=fzero(@(dtg)BVPBeam(yend,dtg),1);
L=3;w=15000;E=200e9;I=30000e-8;
[xn,yn]=ode45(@(x,y)BeamL(x,y,L,w,E,I),[0 L],[0,dtg])
plot(xn,yn(:,1))

function res=BVPBeam(yend,dtg)
L=3;w=15000;E=200e9;I=30000e-8;
[xn,yn]=ode45(@(x,y)BeamL(x,y,L,w,E,I),[0 L],[0,dtg]);
n=length(xn);
yendGuess=yn(n,2);
res=yend-yendGuess;

function dy=BeamL(x,y,L,w,E,I)
dy(1)=y(2);
dy(2)=w*L*x/2/E/I-w*x^2/2/E/I;
dy=dy';

-4
x 10
0

-0.5

-1

-1.5

-2

-2.5

-3
0 0.5 1 1.5 2 2.5 3

11
Section 53
85-220 Numerical Analysis for Engineering Systems
Winter 2014
Tutorial 11
1. The following system of ODE occur in the solution of chemical reaction kinetics:
dc1
 0.013c1  1000c1c3
dt
dc2
 2500c2 c3
dt
dc3
 0.013c1  1000c1c3  2500c2 c3
dt
Solve the system of equations from t = 0 to 50 with initial conditions
( ) ( )
( )
Plot c1 , c2 , and c3 as function of t in the interval t = 0 to 50

Solution:
An attempt to solve the system with generic methods/solvers will fail, since this is a
system of stiff ODE. Method/s for stiff ODE should be used.

clear,clc
[tn,cn]=ode23s(@(t,c)conc(t,c),[0 50],[1 1 0])
plot(tn,cn(:,1),tn,cn(:,2))
figure(2)
plot(tn,cn(:,3))

with

function dc=conc(t,c)
dc(1)=-0.013*c(1)-1000*c(1)*c(3);
dc(2)=-2500*c(2)*c(3);
dc(3)=-0.013*c(1)-1000*c(1)*c(3)-2500*c(2)*c(3);
dc=dc';

12
1.5

0.5
0 5 10 15 20 25 30 35 40 45 50

-6
x 10
0

-1

-2

-3

-4
0 5 10 15 20 25 30 35 40 45 50

2. An insulated heated rod with uniform heat source can be modeled with the Poisson
equation
d 2T
  f ( x)
dx 2
Given the heat source
 x 
f ( x)  0.211sin   1.4 x 2  10e 0.1x
 10 
And the boundary conditions
T ( x  0)  10C, T ( x  10)  250C
Solve for the temperature distribution along the length L = 10m using shooting method.
Plot T as function of x.
Solution:
clear,clc
Tend=250;
dtg=fzero(@(dtg)BVProd(Tend,dtg),1)
[xn,Tn]=ode45(@(x,T)heat_rod(x,T),[0 10],[10,dtg])
plot(xn,Tn(:,1))

function res=BVProd(Tend,dtg)
[xn,Tn]=ode45(@(x,T)heat_rod(x,T),[0 10],[10,dtg]);
n=length(xn);
TendGuess=Tn(n,1);
res=Tend-TendGuess;

13
function dT=heat_rod(x,T)
dT(1)=T(2);
dT(2)=-0.211*sin(pi*x/10)+1.4*x^2-10*exp(0.1*x);
dT=dT';

250

200

150

100

50

-50

-100

-150

-200
0 1 2 3 4 5 6 7 8 9 10

3. A block, having a mass m=7 kg, is immersed in a fluid such that the dumping force is
 
F  (50v ) N , where v is in m/s. If the block is displaced from equilibrium position y(
t=0 ) = 0 and the final displacement y( t = 1 s) =0.0015 m find how the displacement
changes with time in the interval 0 s < t < 1 s. Plot the displacement as a function of time
using that the spring has a stiffness of k = 600N/m. Assume that the positive
displacement is downwards and it is described by
d 2 y 50 dy k
  y0
dt 2 m dt m

Solution:
clear,clc
m=7;
k=600;

14
yend=0.0015;
dtg=fzero(@(dtg)BVP(yend,dtg),1)
[tn,yn]=ode45(@(t,y)spring(t,y,k,m),[0 1],[0 dtg])
plot(tn,yn(:,1))

with functions
function dy=spring(t,y,k,m)
dy(1)=y(2);
dy(2)=-50/m*y(2)-k/m*y(1);
dy=dy';

function res=BVP(Tend,dtg)
m=7;
k=600
[xn,Tn]=ode45(@(t,y)spring(t,y,k,m),[0 1],[0,dtg]);
n=length(xn);
TendGuess=Tn(n,1);
res=Tend-TendGuess;

0.04

0.03

0.02

0.01

-0.01

-0.02
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

15

Вам также может понравиться