PHYS2160 – Lab 5: NumPy and Basic Plotting Solved

$ 29.99
Category:

Description

Exercise 1: Chebyshev Polynomial of the First Kind
AIM:
Write a Python program that uses the NumPy Polynomial class to print a table of the first ten Chebyshev polynomials of the first kind. Here is the table generated by this program:
T_0(x) = 1
T_1(x) = x
T_2(x) = 2*x^2 – 1

ALGORITHM:

PROGRAM:

OUTPUT:

Exercise 2: Sound Intensity from a Point Source

In an experiment, Mary measured the variation of the intensity I of the sound produced by a point source with the distance r from the source. Here is her measurement result:
r (m) 1.0 1.2 1.4 1.6 1.8 2.0 2.2 2.4
I (10โˆ’5 W/m2) 0.987 0.662 0.525 0.373 0.308 0.262 0.191 0.184
On the other hand, physical theories tell us that for a point source of sound of power P, the sound intensity I and the distance r from the source are related by:
P
I = 4 ๏ฐr2
Write a Python program that uses the np.linalg method lstsq to find the best least-square fit of
ln I = m ln r + k
for the given data and then display the fitting result together with the theoretical prediction. Your program should output a table of the values of the fitting parameters m and k found from the fitting and their theoretical values as well as the root-mean-square of the residual of the fitting. Assume that the point source emits sound with a power of P = 4๏ฐร—10โˆ’5 W.
ALGORITHM:

PROGRAM:

OUTPUT:

Exercise 3: Forced Vibration with Damping

A small block of mass m suspended vertically by a spring with spring constant k is driven by an external force F(t) = F0 cos(๏ทt). The block is moving in a viscous medium with a damping force of the form โˆ’bv where b > 0 is the damping constant and v is its instantaneous velocity. Taking downward as the positive direction, the vibration of the block is modeled by the differential equation:
d2x dx
m 2 + b dt + kx = F0 cos(๏ทt) dt
where x(t) is the displacement of the block from its equilibrium position at time t. It can be shown that the steady state solution (i. e. x(t) when time t โ†’ ๏‚ฅ) is
xs(t) = (MF0/k) cos(๏ทt โˆ’๏ฆ)
In this formula, M is the magnification ratio and ๏ฆ is the phase lag defined by
1 2๏บ(๏ท/๏ท
M = 2/๏ท02)2 + 4๏บ (๏ท/๏ท0) , ๏ฆ= tanโˆ’1 [1 โˆ’ (๏ท/๏ท00))2],
โˆš(1 โˆ’ ๏ท 2 2
where ๏ท0 = โˆšk/m is the natural frequency and ๏บ is the damping ratio. Write a Python program that uses the Matplotlib Axes class method plot to plot the magnification ratio M over the interval of frequency ratio ๏ท/๏ท0 from 0 to 2.0 for damping ratio ๏บ = 0.1, 0.2, 0.4, 0.6, and 0.8, respectively, on the same graph. You should label your graph with proper axis labels, title, and legends. From your graph, you can observe how the peak value of M depends on ๏บ, i. e. the effect of damping on the resonance frequency of the block.
ALGORITHM:

PROGRAM:

OUTPUT:

Exercise 4: Employees in Hong Kong’s Construction Industry

Year Number of Employees in Thousands Share of the Employees in the Labour Force
2011 277.0 7.75 %
2012 290.1 7.93 %
2013 309.0 8.30 %
2014 309.7 8.27 %
2015 316.7 8.39 %
2017 342.0 8.95 %
Write a Python program that uses Matplotlib Axes class method twinx to produce a bar chart of the number of employees in Hong Kongโ€™s construction industry and a line plot of the percentage share of these employees in the labour force as a function of year on the same graph. You should label your graph with proper axis labels, title, and legends.
ALGORITHM:

PROGRAM:

OUTPUT:

Reviews

There are no reviews yet.

Be the first to review “PHYS2160 – Lab 5: NumPy and Basic Plotting Solved”

Your email address will not be published. Required fields are marked *