Interactive Shear And Bending Moment Graph plotting in python using Jupyter Notebook
In this blog we are going to learn how to shear force and bending moment diagram of a simple supported beam in jupyter notebook.
Note : While making this code I have used the absolute coordinate system and relative coordinate system
First i have
-import numpy for math calculation
-matplotlib for graph plotting
-ipywidgets to make interactive graph in Jupyter notebook
In our case i am using simply support beam so first thing i have do is define the length of the beam . The starting point of the beam(s_b) and ending point of beam(e_b) .The value will be read as (0,0) and (10,0) as straight line this line represent straight beam.
Now we have to define a function with a variable that can be used as slider in my case the function name is fd(force downward) and the parameter is x (distance from the left side).
We are going to use subplot becasue we have to plot 3 graph , simply supported beam , shear force diagram and bending moment diagram
plt.arrow(x,50,0,-49,width = .001,head_length = 1,head_width= .1)
x,50 # these two point represent starting point of arrow
0,-49 #the two represend magnitude of x and y direction
width = width of the arrow
head_length and head_width = basically means arrow head length and width respectively.
After that, we have use a simple shear force diagram concept nothing special. If you face any difficulty understanding feel free to comment I will edit this blog as per for your convenience.
import numpy as np
import matplotlib.pyplot as plt
from ipywidgets import interactive
s_b = [0,10] #starting point of beam
e_b = [0,0] #ending point of beam
def fd(x):
plt.figure(figsize = (15,15))
#fig, ax = plt.subplots(figsize=(3, 3))
plt.subplot(3,1,1)
plt.plot(s_b,e_b)
plt.title('Simply supported Beam Diagram')
plt.xlabel('Lenght of the beam')
plt.ylabel('Point load on beam')
plt.arrow(x,50,0,-49,width = .001,head_length = 1,head_width= .1)
#shear force diagram
plt.subplot(3,1,2)
f = 50
fx =[0,x,10]
fy =[0,f*(10-x)/10,0]
plt.title('Shear Force Diagram')
plt.xlabel('Lenght of the beam')
plt.ylabel('Point Load on beam')
plt.plot(s_b,e_b,fx,fy)
plt.subplot(3,1,3)
y = f*(10-x)/10
sfx =[0,0,x,x,x,10,10]
sfy =[0,y,y,0,-y,-y,0]
plt.title('Bending Moment Diagram')
plt.xlabel('Lenght of the beam')
plt.ylabel('Point Load on beam')
plt.plot(s_b,e_b,sfx,sfy)
interactive_plot = interactive(fd ,x = (0,10),step =10)
interactive_plot
Other Blog you might like to read : Deflection of Beam , Slope Diagram in Python
0 Comments
if you are not getting it then ask i am glad to help