COMPUTER AIDED ANALYSIS AND MODELLING Lectures
COMPUTER AIDED ANALYSIS AND MODELLING Lectures
COMPUTER AIDED ANALYSIS AND MODELLING Lectures
DR. R. OPOKU
INTRODUCTION
The aim of this course is to introduce students to:
• numerical methods as well as acquire practical skills in the use of
computer to model and solve mechanical engineering problems.
• the course will focus on the use of available tools such as: MATLAB,
MathCAD, etc. to solve mechanical engineering problems.
̒
• Subscripts can be obtained by using underscore symbol ̒̒ ̒_̓ ̓. For example,
y_1 generates y1
y_2 generates y2
Superscripts can be generated by using ̒̒ ̒^ ̓ ̓. For example,
x^2 generates x2
• x^3 generates x3
Monday, September 2, 2019 ME 581 COMPUTER AIDED ANALYSIS & MODELING
10
Some Rational and Logical Operators in MATLAB
< Less than
< = Less than or equal
> Greater than
> = Greater than or equal
= = Equal
~ = Not equal
The logical operators are
& AND
| OR
~ NOT
Use of colon. The colon plays an important role in MATLAB, being involved in creating
vectors, subscripting matrices and specifying iterations. For example, the statement t = 1:5
• generates a row vector containing the numbers from 1 to 5 with unit increment-that is, t
=1 2 3 4 5
• The colon is frequently used to subscript matrices. A(:,j) is the jth column of A and A(i,:) is
the ith row of A. For example, if matrix A is given by
1 2 3
• 𝐴= 4 5 6
7 8 9
• the A(:,3) gives the third element in all of the rows (i.e., the third column), as follows:
3
6
9
• A(2,:) gives the second row of A, namely,
4 5 6
Monday, September 2, 2019 ME 581 COMPUTER AIDED ANALYSIS & MODELING
13
• x = linspace(min,max,increment)
• Example: x = linspace(-10,10,5) will give
x = -10 -5 0 5 10
• Array division. The expressions x./y, x.\y, and A./B, gives the
quotients of the individual elements. Thus for
• x = [1 2 3], y = [4 5 6]
• For r = [-3 -2 -1], poly(r) will produce the polynomial equation: s3 + 6s2
+ 11s + 6 = 0
>>a = [3 10 25 36 50];
>>b = [1 2 10];
>>% Define the quotient and remainder of a/b as q and r, respectively.
>>[q,r] = deconv (a, b)
q=
3 4 -13
r=
0 0 0 22 180
In the analysis of fluid flow, you will need to first identify the type of
flow as either laminar flow or turbulent flow, by determining the Re #.
Monday, September 2, 2019 ME 581 COMPUTER AIDED ANALYSIS & MODELING
25
Laminar vs Turbulent Flow
• Laminar Flow
• Flow dominated by viscous
forces is called laminar flow
and is characterized by a
smooth, parallel line motion
of the fluid
• Turbulent Flow
• When inertia forces
dominate, the flow is called
turbulent and it is
characterized by an
irregular motion of the fluid.
( H1 H 2 ) dH m s
R ; units 3 2
Q dQ m / s m
Monday, September 2, 2019 ME 581 COMPUTER AIDED ANALYSIS & MODELING
28
Resistance in Laminar Flow • Reading assignment: find the resistance if the
flow was turbulent.
• For laminar flow, the relationship
between the steady-state flow rate
and steady state height at the
restriction is given by: Q k H
l
dH 1 H
• The resistance Rl is: Rl
dQ K l Q
Monday, September 2, 2019 ME 581 COMPUTER AIDED ANALYSIS & MODELING
29
Capacitance of Liquid-Level Systems
• The capacitance of a tank is defined to be the • Reading assignment: Write out the equation to
change in quantity of stored liquid necessary to determine the capacitance of a conic tank.
cause a unity change in the height.
dV d ( A h) A dh h dA
C
dh dh dh
• Note that for uniform cross-section, the
Capacitance (C) is the cross sectional area (A) of
the tank.
dh h
C qi
dt R
• After simplifying above equation
dh
RC h Rqi .............(1B)
dt
• Equation 1B can be solved numerically to obtain the system response (h)
• Note that RC is the time constant of the system
Monday, September 2, 2019 ME 581 COMPUTER AIDED ANALYSIS & MODELING
35
Tutorial
• A relay tank used at an oil processing company which
has diameter 4 meters and height 8 meters maintains a
steady liquid level of 6.5 meters at a flow rate of 20 cubic
meter per second. Find the change in the liquid level if
the inlet flow valve is adjusted such that the flow rate
increases in the following cases: by 10%, 20%, 30% and
40%; whilst the outflow valve is still kept at its position.
Assume the flow is laminar.
• clf % this clears the chart for replotting the figure • h(i+1)=0.245*(0.325*q_in-h(i))*dt+h(i);
when you re-run code • end
• Q_in=20; %mass flow rate of 20 kg/s • hold all
• h(1)=0;% initial change in height from the steady • plot(t/60,h,'*-','LineWidth',3)
height • xlabel('time [minutes]')
• tmax=1*60; % time duration in seconds • ylabel('change in liquid level [meters]')
• dt=1; %time step • title('Change in Liquid-level versus time')
• t=0; %initialize • grid on
• iter_max=tmax/dt; • end
• legend('10% increment','20% increment','30%
increment','40% increment')
Monday, September 2, 2019 ME 581 COMPUTER AIDED ANALYSIS & MODELING
38
Solution Plot with MATLab
Change in Liquid-level versus time
3
1.5
0.5
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
time [minutes]
Monday, September 2, 2019 ME 581 COMPUTER AIDED ANALYSIS & MODELING
39
• End of Lecture 2