How to plot shear force and bending moment diagram?
import math
import matplotlib.pyplot as plt
#Variable Decleration
w1=400 #UDL in lb/ft
P=400 #Point load at C in lb
w2=200 #UDL in lb/ft
L1=2 #Length in ft
L2=1 #Length in ft
L3=4 #Length in ft
V_A=0 #Shear force at A in lb
Rb=-1520 #Reaction at B in lb
Rd=-880 #Reaction at D in lb
d=1.6 #Distance in ft
#Calculations
#The plotting of the Shear force diagram and the Bending Moment Diagram
#Will be done different from that done in the textbook
#Calculations for Shear Force
Area1=P*L1 #Area of w diagram from A to B
Area2=0 #Area of w diagram from B to C
Area3=w2*L3 #Area of w diagram from C to D
V_B_left=V_A-Area1 #Shear Force at left of B in lb
V_B_right=V_B_left-Rb #Shear force at right of B in lb
V_C_left=V_B_right-Area2 #Shear Force at left of C in lb
V_C_right=V_C_left-P #Shear Force at right of C in lb
V_D_left=V_C_right-Area3 #Shear Force at left of D in lb
V_D_right=V_D_left-Rd #Shear Force at right of D in lb
V_E=0 #Shear Force at E in lb
#Calculations for Bending Moments
AreaV1=0.5*L1*V_B_left #Area of V diagram
AreaV2=V_C_left*L2 #Area of V diagram from B to C
AreaV3=V_D_left*(L3-d)*0.5 #Area of V diagram from F to D
M_A=0 #Moment at A in lb.ft
M_B=M_A+AreaV1 #Moment about B in lb.ft
M_C=M_B+AreaV2 #Moment about C in lb.ft
M_F=M_C+V_C_right*0.5*d #Moment about F in lb.ft
M_D=M_F+AreaV3 #Moment about D in lb.ft
M_E=0 #Moment about E in lb.ft
#Result
print ("The following plots are the results")
#Plotting
#Shear Force
x=[0,L1,L1+0.000001,L1+d,L1+d+0.000001,L1+L3,L1+L3+0.000001,L1+L3+L1]
V=[V_A,V_B_left,V_B_right,V_C_left,V_C_right,V_D_left,V_D_right,V_E]
zero=[0,0,0,0,0,0,0,0]
plt.plot(x,V,x,zero)
plt.xlabel("Length in ft")
plt.ylabel("Shear Force in lb")
plt.title("Shear Force Diagram")
plt.show()
#Bending Moment
x1=[0,L1,L1+L2,L1+L2+d,L1+L3,L1+L3+L1]
BM=[M_A,M_B,M_C,M_F,M_D,M_E]
zero1=[0,0,0,0,0,0]
plt.plot(x1,BM,x1,zero1)
plt.xlabel("Length in ft")
plt.ylabel("Bending Moment in lb.ft")
plt.title("Bending Moment Diagram")
plt.show()
#The Bending Moment Diagram differs from that in the textbook because of curve type
0 Comments
if you are not getting it then ask i am glad to help