Skip to article frontmatterSkip to article content

1.6Examples, exercises and solutions

1.6.1Exercises

Source
# Moving a box

## Importing libraries
import numpy as np
import matplotlib.pyplot as plt

## Constants
m = 2 #kg
F = 30 #N
g = 9.81 #m/s^2
theta = np.deg2rad(10) #degrees

## Time step
dt = 0.01 #s
t = np.arange(0, 10, dt) #s
t_F_stop = ..

## Initial conditions
x = np.zeros(len(t)) #m
v = np.zeros(len(t)) #m/s


## Loop to calculate position and velocity
for i in range(1, len(t)):
    if t[i] < ..:
        a = F/m - g*np.sin(theta)
    else:
        a = -g*np.sin(theta)
    v[i] = v[i-1] + ..
    x[i] = x[i-1] + v[i]*dt

## Plotting results
figs, axs = plt.subplots(1, 2, figsize=(10, 5)) 

axs[0].set_xlabel('Time (s)')
axs[0].set_ylabel('Velocity (m/s)')
axs[0].plot(t, v, 'k.', markersize=1)


axs[1].set_xlabel('Time (s)')
axs[1].set_ylabel('Position (m)')
axs[1].plot(t, x, 'k.', markersize=1)



plt.show()

1.6.2Solutions

Solution to Exercise 1
F=kv2[kgms2]=[.][m2s2][.]=[kgm]\begin{aligned} F &= k v^2\\ [\frac{\text{kgm}}{\text{s}^2}] &= [.][\frac{\text{m}^2}{\text{s}^2}] \Rightarrow [.]=[\frac{\text{kg}}{\text{m}}] \end{aligned}
Solution to Exercise 2

To be processed

Solution to Exercise 3

To be processed

Solution to Exercise 4
  1. =1012=10^{-12}
  2. =1021=10^{21}
  3. =103=10^{-3}
Solution to Exercise 5
# Moving a box

## Importing libraries
import numpy as np
import matplotlib.pyplot as plt


part_4 = 1 # Turn to 0 for first part

## Constants
m = 2 #kg
F = 30 #N
g = 9.81 #m/s^2
theta = np.deg2rad(10) #degrees

mu = 0.02
F_N = m*g*np.cos(theta) #N

## Time step
dt = 0.01 #s
t = np.arange(0, 10, dt) #s
t_F_stop = 0.5

## Initial conditions
x = np.zeros(len(t)) #m
v = np.zeros(len(t)) #m/s


## Loop to calculate position and velocity
for i in range(0, len(t)-1):
    if t[i] < t_F_stop:
        a = F/m - g*np.sin(theta) - F_N*mu*np.where(v[i] != 0, np.sign(v[i]), 0)*part_4
    else:
        a = -g*np.sin(theta) - F_N*mu*np.where(v[i] != 0, np.sign(v[i]), 0)*part_4
    v[i+1] = v[i] + a*dt
    x[i+1] = x[i] + v[i]*dt

## Plotting results
figs, axs = plt.subplots(1, 2, figsize=(10, 5)) 

axs[0].set_xlabel('Time (s)')
axs[0].set_ylabel('Velocity (m/s)')
axs[0].plot(t, v, 'k.', markersize=1)


axs[1].set_xlabel('Time (s)')
axs[1].set_ylabel('Position (m)')
axs[1].plot(t, x, 'k.', markersize=1)



plt.show()
Solution to Exercise 6
# Simulation of a base jumper 

## Importing libraries
import numpy as np
import matplotlib.pyplot as plt

## Constants
A = 0.7 #m^2
m = 75 #kg
k = 0.37 #kg/m
g = 9.81 #m/s^2

## Time step
dt = 0.01 #s
t = np.arange(0, 12, dt) #s

## Initial conditions
z = np.zeros(len(t)) #m
v = np.zeros(len(t)) #m/s
z[0] = 300 #m

## Deploy parachute
A_max = 42.6 #m^2
t_deploy_start = 2 #s
dt_deploy = 3.8 #s

## Loop to calculate position and velocity
for i in range(0, len(t)-1):
    F = - m*g - k*A*abs(v[i])*v[i]  #N
    v[i+1] = v[i] + F/m*dt #m/s
    z[i+1] = z[i] + v[i]*dt #m
    # Check if the jumper is on the ground
    if z[i+1] < 0:
        break
    # Deploy parachute
    if t[i] > t_deploy_start and t[i] < t_deploy_start + dt_deploy:
        A += (A_max - A)/dt_deploy*dt 

## Plotting results
figs, axs = plt.subplots(1, 2, figsize=(10, 5)) 

axs[0].set_xlabel('Time (s)')
axs[0].set_ylabel('Velocity (m/s)')

axs[0].plot(t, v, 'k.', markersize=1, label='numerical solution')
axs[0].vlines(t_deploy_start, v[t==t_deploy_start],0, color='gray', linestyle='--', label='parachute deploy')

axs[0].legend()

axs[1].set_xlabel('Time (s)')
axs[1].set_ylabel('Position (m)')

axs[1].plot(t, z, 'k.', markersize=1)
axs[1].vlines(t_deploy_start, 150,300, color='gray', linestyle='--', label='parachute deploy')


plt.show()
Solution to Exercise 7
import numpy as np
import matplotlib.pyplot as plt

F = 49/3
m1 = 1
dt = 0.001
t = np.arange(0, 100, dt) # s

x1 = np.zeros(len(t)) # m
x1[0] = 3
y1 = np.zeros(len(t)) # m
vx = 0
vy = 7


for i in range(0, len(t)-1):
    ax = -F*(x1[i]-0)/np.sqrt(x1[i]**2 + y1[i]**2)
    ay = -F*(y1[i]-0)/np.sqrt(x1[i]**2 + y1[i]**2)
    vx = vx + ax*dt
    vy = vy + ay*dt
    x1[i+1] = x1[i] + vx*dt
    y1[i+1] = y1[i] + vy*dt


plt.figure(figsize=(4,4))
plt.plot(x1, y1, 'k.', markersize=1)
plt.xlabel('x (m)')
plt.ylabel('y (m)')
plt.show()
Footnotes
  1. Exercise from Idema, T. (2023). Introduction to particle and continuum mechanics. Idema (2023)

References
  1. Idema, T. (2023). Introduction to particle and continuum mechanics. TU Delft OPEN Publishing. 10.59490/tb.81