# Example 24.1 Simple Harmonic Motion¶

In :
import math
# Initilization of variables
f=1/6 # oscillations/second
x=8 # cm # distance from the mean position
# Calculations
omega=2*math.pi*f
# Amplitude is given by eq'n
r=math.sqrt((25*x**2)/16) # cm
# Maximum acceleration is given as,
a_max=(math.pi/3)**2*10 # cm/s^2
# Velocity when it is at a dist of 5 cm (assume s=5 cm) is given by
s=5 # cm
v=omega*math.sqrt(r**2-s**2) # cm/s
# Results
print('(a) The amplitude of oscillation is %d cm'%r)
print('(b) The maximum acceleration is %f cm/s**2'%a_max)
print('(c) The velocity of the particle at 5 cm from mean position  is %f cm/s'%v)

(a) The amplitude of oscillation is 10 cm
(b) The maximum acceleration is 10.966227 cm/s**2
(c) The velocity of the particle at 5 cm from mean position  is 9.068997 cm/s


# Example 24.2 Simple Harmonic Motion¶

In :
import math
# Initilization of variables
x_1=0.1 # m # assume the distance of the particle from mean position as (x_1 & x_2)
x_2=0.2# m
# assume velocities as v_1 & v_2
v_1=1.2 # m/s
v_2=0.8 # m/s
# Calculations
# The amplitude of oscillations is given by dividing eq'n 1 by 2 as,
r=math.sqrt(0.32/5) # m
t=(2*math.pi)/omega # seconds
v_max=r*omega # m/s
# let the max acceleration be a which is given as,
a=r*omega**2 # m/s**2
# Results
print('(a) The amplitude of oscillations is %f m'%r)
print('(b) The time period of oscillations is %f seconds'%t)
print('(c) The maximum velocity is %f m/s'%v_max)
print('(d) The maximum acceleration is %f m/s**2'%a) # the value of max acc is incorrect in the textbook
# NOTE: the value of t is incorrect in the text book
# The values may differ slightly due to decimal point accuracy

(a) The amplitude of oscillations is 0.252982 m
(b) The time period of oscillations is 1.216734 seconds
(c) The maximum velocity is 1.306395 m/s
(d) The maximum acceleration is 6.746192 m/s**2


# Example 24.5 Equivalent spring constant¶

In :
import math
# Initilization of variabes
W=50 # N # weight
x_0=0.075 # m # amplitude
f=1 # oscillation/sec # frequency
g=9.81
# Calculations
omega=2*math.pi*f
K=(((2*math.pi)**2*W)/g)*(10**-2) # N/cm
# let the total extension of the string be delta which is given as,
delta=(W/K)+(x_0*10**2) # cm
T=K*delta # N # Max Tension
v=omega*x_0 #m/s # max velocity
# Results
print('(a) The stiffness of the spring is %f N/cm'%K)
print('(b) The maximum Tension in the spring is %f N'%T)
print('(c) The maximum velocity is %f m/s'%v)

(a) The stiffness of the spring is 2.012152 N/cm
(b) The maximum Tension in the spring is 65.091138 N
(c) The maximum velocity is 0.471239 m/s


# Example 24.10 Pendulum Motion¶

In :
import math
# Initilization of variables
l=1 # m # length of the simple pendulum
g=9.81 # m/s^2
# Calculations
# Let t_s be the time period when the elevator is stationary
t_s=2*math.pi*math.sqrt(l/g) #/ seconds
# Let t_u be the time period when the elevator moves upwards. Then from eqn 1
t_u=2*math.pi*math.sqrt((l)/(g+(g/10))) # seconds
# Let t_d be the time period when the elevator moves downwards.
t_d=2*math.pi*math.sqrt(l/(g-(g/10))) # seconds
# Results
print('The time period of oscillation of the pendulum for upward acc of the elevator is %f seconds'%t_u)
print('The time period of oscillation of the pendulum for downward acc of the elevator is %f seconds'%t_d)

The time period of oscillation of the pendulum for upward acc of the elevator is 1.912710 seconds
The time period of oscillation of the pendulum for downward acc of the elevator is 2.114580 seconds


# Example 24.11 Pendulum Motion¶

In :
import math
# Initilization of variables
t=1 # second # time period of the simple pendulum
g=9.81 # m/s^2
# Calculations
# Length of pendulum is given as,
l=(t/(2*math.pi)**2)*g # m
# Let t_u be the time period when the elevator moves upwards. Then the time period is given as,
t_u=2*math.pi*math.sqrt((l)/(g+(g/10))) # seconds
# Let t_d be the time period when the elevator moves downwards.
t_d=2*math.pi*math.sqrt(l/(g-(g/10))) # seconds
# Results
print('The time period of oscillation of the pendulum for upward acc of the elevator is %f seconds'%t_u)
print('The time period of oscillation of the pendulum for downward acc of the elevator is %f seconds'%t_d)

The time period of oscillation of the pendulum for upward acc of the elevator is 0.953463 seconds
The time period of oscillation of the pendulum for downward acc of the elevator is 1.054093 seconds


# Example 24.12 Pendulum Motion¶

In :
import math
# Initilization of variables
m=15 # kg # mass of the disc
D=0.3 # m # diameter of the disc
l=1 # m # length of the shaft
d=0.01 # m # diameter of the shaft
G=30*10**9 # N-m**2 # modulus of rigidity
# Calculations
# M.I of the disc about the axis of rotation is given as,
I=(m*R**2)/2 # kg-m**2
# Stiffness of the shaft

The time period of oscillations of the disc is 0.475599 seconds