Civil Thinking

Below is the Python code to draw Shear and Moment Diagram of this simply supported beam carrying uniformly distributed load:

import numpy as np
import matplotlib.pyplot as plt
l=5 #m
q=20 #kN/m
x= np.linspace(0,l,200)
#SFD
V=q*(l/2-x)
M=q/2*(l*x-x**2)
print(V)
print(M)
plt.plot(x,V)
plt.axhline(0, color='k')
plt.fill_between(x, V,0)
plt.title("Shear Force Diagram(SFD)")
plt.xlabel("x(m)")
plt.ylabel("V(kN)")
i_zero=np.argmin(np.abs(V))
plt.plot(x[i_zero],V[i_zero], 'ro')
plt.text(x[i_zero],V[i_zero]+3,round(x[i_zero],1))

#BMD
plt.figure()
plt.plot(x,M)
plt.axhline(0, color='k')
plt.fill_between(x, M,0)
plt.title("Bending Moment Diagram(BMD))")
plt.xlabel("x(m)")
plt.ylabel("M(kNm)")
#i_zero=np.argmin(np.abs(V))
plt.plot(x[i_zero],M[i_zero], 'ro')
plt.text(x[i_zero],M[i_zero]-3,round(M[i_zero],1))
plt.show()

Below is a detailed and comprehensive tutorial to learn this code:

If you need help with any Python Project/Question feel free to contact us using the form below:

Results using Python:

Leave a Reply

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