Skip to content

Instantly share code, notes, and snippets.

View joreilly86's full-sized avatar

James O'Reilly joreilly86

View GitHub Profile
@joreilly86
joreilly86 / #027 - Data Structures for Engineers: Pandas 101.py
Last active April 12, 2024 15:10
#027 - Data Structures for Engineers: Pandas 101
# -----------------------------------------------------------------------------
# #027 - Data Structures for Civil/Structural Engineers: Pandas 101
# -----------------------------------------------------------------------------
'''
Hi everybody from the flocode newsletter 👋
This is all the code from article #027 - Data Structures for Civil/Structural Engineers:
Pandas 101
@joreilly86
joreilly86 / #027 - Thinking Programmatically.py
Last active March 26, 2024 23:47
Sample code from Substack Post
# ==========================================================
# Prepare Pseudocode for Calculating Concrete Volume
# ==========================================================
FUNCTION calculate_concrete_volume(length, width, depth)
# Calculate the area of the floor slab
area = length * width
# Calculate the volume of concrete required
@joreilly86
joreilly86 / 023_numpy_example.py
Created February 23, 2024 16:37
Numpy example from Flocode Newsletter #023 - The Best Python Libraries for Civil/Structural Engineering
import numpy as np
# Constants
M = 140 # Moment at the cross-section (kN.m)
I = 102_000_000 # Moment of inertia in mm^4
y = np.array([-150, -100, -50, 0, 50, 100, 150]) # Distance from the neutral axis in mm
# Bending stress calculation
sigma = ((M * 1e6) * y) / I # Convert M from kN.m to N.mm
@joreilly86
joreilly86 / simply_supported_beam_function.py
Created February 8, 2024 19:37
Function for simply supported beam
import numpy as np
import matplotlib.pyplot as plt
def plot_beam_diagrams(length, w):
"""
Plot the shear force and bending moment diagrams for a simply supported beam.
Parameters:
- length: Length of the beam (m)
- w: Magnitude of the uniformly distributed load (kN/m)
@joreilly86
joreilly86 / simply_supported_beam.py
Created February 5, 2024 05:22
#23 - A Simply Supported Beam in Python, a simple code snippet for calculating and plotting the shear force and bending moment diagrams for a beam under a uniformly distributed load.
import numpy as np
import matplotlib.pyplot as plt
# Beam parameters
length = 10 # Length of the beam (m)
w = 10 # Uniformly distributed load in kN/m
# Functions
def shear_force(x):
return w * (length / 2 - x) # kN