IndeterminateBeam: How to use an open-source Python library for structural beam design

How to write your own Python script for structural beam analysis
July 17, 2023
MJ
MJ
Longinos

IndeterminateBeam is a Python package designed to help Engineers with one of the most common structural problems: Beam Analysis. In this article we describe how you can get started with the library. This versatile module serves as both a stand-alone program and a comprehensive tool for determining reaction forces, internal forces (shear, bending, axial), deflections of beams, and generating axial force, shear force, bending moment, and deflection diagrams. By leveraging engineering concepts of statics and utilizing Python packages like Sympy and Plotly, IndeterminateBeam provides engineers with a powerful solution for beam analysis.

The IndeterminateBeam package is primarily based on engineering concepts of statics, drawing inspiration from renowned author Hibbeler's work in 2013. It leverages Python packages such as Sympy (Meurer et al., 2017) and Plotly (Plotly Technologies Inc, 2015) to enhance its functionality and visualization capabilities. The package documentation provides a concise overview of the theoretical foundations used to calculate forces on indeterminate beams. Detailed documentation is available for reference, offering comprehensive information on the package's features and usage. 

Additionally, users can explore text-based examples of the package's capabilities in a Jupyter Notebook, while a web-based graphical user interface (GUI) is accessible over here, providing a user-friendly interface for utilizing the package's functionality.

Project Purpose

The purpose of this project is two-fold:

  1. Create a free website that has more features than paid and free beam calculators that exist on the web.
  2. Provide a foundation for civil and structural engineers who want to create higher order engineering Python programs.

Several (mostly paid) beam calculator websites currently exist online, providing the same service as this package. Despite this, no online service exists (to the authors knowledge) that has all the features of IndeterminateBeam and is also free.

Similiarly, there are no well-documented indeterminate beam solving Python packages (to the authors knowledge) despite the importance of such a calculation in engineering. Several python finite element analysis (FEA) packages do exist, however they are vastly overcomplicated for someone wanting to only solve for forces on a one-dimensional beam.

This python package was heavily inspired by beambending (Carella, 2019), a module created for educational purposes by Alfredo Carella of the Oslo Metropolitan University. The beambending module, although well documented, can only solve for simply supported beams consisting of a pin and roller support. The package documentation for this project includes a more rigorous overview of the theory behind the basics for solving determinate structures.

Functionality and Usage

A typical use case of the IndeterminateBeam package involves the steps below:

  1. Create a Beam object
  2. Create Support objects and assign to Beam
  3. Create Load objects and assign to Beam
  4. Solve for forces on Beam object
  5. Plot results

You can follow along with the example below in this web-based Jupyter Notebook. Alternatively, you can download the jupyter-notebook for this example here, or the python file for this code here.

The units used throughout the Python package are the base SI units (newtons and metres), but can be updated using the update_units method. Units and load direction conventions are described in the package documentation.

1. Learn how to build your own tools - Python for Civil Engineering Certification

If you’d like a guided path to mastering the libraries above, watch the two‑minute overview below. You’ll see the four web‑based tools we build during the Python for Civil Engineering Certification and learn how each one replaces hours of manual spreadsheet work.

What You Will Build Inside the Certification

Across seven bite‑sized modules you will craft four deployable apps that replace hours of manual work. Expand each panel below for a short preview:

We use Python to publish your Beam Analysis tool onto the web

  • Follow along in this practical lesson where we build this tool together.
  • Our tool will input beam length, beam properties, support conditions and loading conditions.
  • Using an open-source Python library our application will run calculations automatically to calculate deflection, bending moment, shear force and reactions.
  • We will then publish our application onto the web so that it can be used on any of our devices.
  • The tool we build will be similar to the version here, except we will be able to customise it further and self-host it.

We use Python to publish your Concrete Design Tool onto the web

  • Follow along in this practical lesson where we build this tool together.
  • Our tool will input concrete properties, steel properties and the overall section size and rebar distribution.
  • Using an open-source Python library our application will calculate a full range of section properties (including centroid position, second moment of area) and generate our M-N Plots for our design calculations.
  • We will then publish our application onto the web so that it can be used on any of our devices.
  • The tool we build will be similar to the version here, except we will be able to customise it further and self-host it.

We use Python to publish your Slope Stability Analysis Tool onto the web

  • Follow along in this practical lesson where we build this tool together.
  • Our tool will input slope profile (height and length) multiple layers of geology (and their geotechnical design properties), loading conditions around the slope and water conditions.
  • Using an open-source Python library our application will calculate the Factor of Safety based upon the Bishop's Method of Slices and display the factor of safety and sensitivity analysis for the slope.
  • We will then publish our application onto the web so that it can be used on any of our devices.
  • The tool we build will be similar to the version here, except we will be able to customise it further and self-host it.

We use Python to publish your 3D Frame Analysis Tool onto the web

  • Follow along in this practical lesson where we build this tool together.
  • Our tool will input node coordinates and fixity conditions of a 3D frame and input node loading conditions
  • Using an open-source Python library our application will calculate deflections and deformed mesh of the frame in a 3D visualisation using the Finite Element Analysis approach.
  • We will then publish our application onto the web so that it can be used on any of our devices.
  • The tool we build will be similar to the version here, except we will be able to customise it further and self-host it.

Join 300+ civil & structural engineers already automating their design workflows with the Python for Civil Engineering certification. Stop wrestling with spreadsheets—build your own web-based tools instead!

Explore the Course →

Creating a Beam

Engineers can create a Beam object by specifying the beam length (m) and optionally inputting Young's Modulus (E), second moment of area (I), and cross-sectional area (A). The default values correspond to a steel 150UB18.0 beam. The beam properties impact deflections but do not alter force distributions unless spring supports are employed.

from indeterminatebeam import Beam
# Create 7 m beam with E, I, A as defaults
beam = Beam(7)                          
# Create 9 m beam with E, I, and A assigned by user
beam_2 = Beam(9, E=2000, I=10**6, A=3000)     

Defining Supports

Support objects are created separately from the Beam object. Engineers can define supports by specifying the x-coordinate (m) and translational and rotational degrees of freedom. The degrees of freedom are represented by a tuple of booleans, where 1 denotes fixed support and 0 indicates a free support. Stiffness can also be specified in translational directions, overriding the boolean values.

from indeterminatebeam import Support
# Defines a pin support at location x = 5 m  
a = Support(5, (1,1,0))      
# Defines a roller support at location x = 0 m
b = Support(0, (0,1,0))      
# Defines a fixed support at location x = 7 m
c = Support(7, (1,1,1))      
# Assign the support objects to a beam object created earlier
beam.add_supports(a,b,c)    

Defining Loads

Load objects are created independently and vary based on the type of loading. PointLoadV represents a point load, DistributedLoadV denotes a distributed load, and PointTorque signifies a point torque. Engineers can define the force and coordinate values accordingly.

from indeterminatebeam import PointLoadV, PointTorque, DistributedLoadV
# Create a 1000 N point load at x = 2 m
load_1 = PointLoadV(1000, 2)
# Create a 2000 N/m UDL from x = 1 m to x = 4 m
load_2 = DistributedLoadV(2000, (1, 4))
# Defines a 2 kN.m point torque at x = 3.5 m
load_3 = PointTorque(2*10**3, 3.5)
# Assign the load objects to the beam object
beam.add_loads(load_1,load_2,load_3)

Solving for Forces

After assigning Load and Support objects to the Beam, engineers can call the analyze() function to solve for reactions and internal forces.

beam.analyse()  

Plotting Results

Once the Beam has been analyzed, engineers can utilize the plot_beam_external() and plot_beam_internal() methods to generate visual representations of the results, including axial force, shear force, bending moment, and deflection diagrams.

fig_1 = beam.plot_beam_external()
fig_1.show()

fig_2 = beam.plot_beam_internal()
fig_2.show()

The plot_beam_external and plot_beam_internal methods collate otherwise seperate plots.

The above script produces the following:

Installing the package

If you want to install the indeterminatebeam package, you run this one-liner:

pip install indeterminatebeam

NOTE: You need Python 3 to install this package (you may need to write pip3 instead of pip).

The library dependencies are listed in the file requirements.txt, but you only need to look at them if you clone the repository. If you install the package via pip, the listed dependencies should be installed automatically.

Learning how to code and develop your own civil engineering analysis scripts can be an incredibly valuable skill for both engineering students and professionals. In today's digital age, where technology plays a significant role in engineering practices, the ability to create customized analysis scripts opens up a world of opportunities and benefits. It empowers engineers to take control of their analysis processes, offering greater flexibility, efficiency, and customization. It enhances problem-solving skills, deepens engineering knowledge, and future-proofs professional capabilities. As technology continues to shape the engineering industry, the ability to code analysis scripts becomes an invaluable asset, enabling engineers to adapt, innovate, and thrive in the digital age.

At civils.ai, we understand the importance of empowering civil engineers with the knowledge and tools to develop their own analysis tools. That's why we go the extra mile by not only providing the necessary information and resources for engineers to create their own analysis tools but also offering a ready-made beam analysis calculator that is accessible to all, free of charge.

We believe in promoting innovation and productivity in the civil engineering community. By offering free calculators at civils.ai we aim to eliminate the need for engineers to spend time and effort on developing their own tools from scratch. 

Reference

https://github.com/JesseBonanno/IndeterminateBeam

 


Interested in learning about how you can use AI in your Civil Engineering workflow?
Learn more