Beam Theory Calculus with Python

With Python Sympy

Installing Dependencies

pip install sympy
pip3 install sympy

The Problem

Solve for Shear Force, Bending Moment and Deflection/Elastic Curve.

Question

Result

Question Question Question Question

Solution

# Author: Hasi
# QuantumNovice.github.io
from sympy import *
from sympy.physics.continuum_mechanics.beam import Beam
import matplotlib.pyplot as plt

from matplotlib import style
style.use('ggplot')
init_printing()

# Set R1, R2 to sympy symbols i.e unknowns
R1, R2 = symbols('R1 R2')

# Geometric property of beam (can be calculated using some algorithm)
I = 260.762

# Modulus of Elasticity
E = (29*10**6)

# My Class Number, this was assignment
roll = 45


'''
Note : E and I can also be made unknowns, in which case only shear
and bending moment diagrams will be made.
>> E, I = symbols('E, I')
'''
# Length of beam is 9 ft with modulus of elasticity E and moment of inertia I  
b = Beam(9, E, I)

'''
Applies load on beam object
The first argument is the load
Second Argument is the start position of load i.e x=0
Third Argument is degree of load curve i.e (UDL, line)
Fourth Argument is end position of non-point load i.e x = 2
'''
b.apply_load(-roll*3.5, 0, 0, end=2)
'''
Apply unknown reaction R1 at position x=2ft.
The third argument is the degree argument and the value -1
indicates a point load.
'''
b.apply_load(R1, 2, -1)
'''
Applies point load at position x=3ft
'''
b.apply_load(-roll*3.5, 3, -1)
'''
Another UDL from x=3 to x=9
with load roll no * 1.5
'''
b.apply_load(-roll*1.5, 3, 0, end=9)
'''
Apply unknown reaction R1 at position x=7ft.
The third argument is the degree argument and the value -1
indicates a point load.
'''
b.apply_load(R2, 7, -1)
'''
This adds fix support to the following coordinates. i.e deflection will be zero.
'''
b.bc_deflection = [(0, 0), (9, 0)]

## Another way of doing the above
##b.bc_deflection.append((0,0))
##b.bc_deflection.append((12,0))
##b.bc_slope.append((0,0))

# Computes value of R1 and R2 from static equilibrium
b.solve_for_reaction_loads(R1, R2)

print(b.reaction_loads)


## Print characteristics of diagrams
##print(b.max_shear_force())
##print(b.max_bmoment())
##print(b.point_cflexure())
##print(b.max_defelection())

b.plot_shear_force()
b.plot_bending_moment()
b.plot_slope()
b.plot_deflection()
b.plot_loading_results()