This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ---- FULL CONSOLIDATED SCRIPT FROM FLOCODE NEWSLETTER #068 - Structuring Engineering Calculations in Python | 01 - The Basics | |
# https://flocode.substack.com/ | |
import math # Provides math constants (pi) and functions (sqrt) | |
# ---- FUNDAMENTAL INPUT PARAMETERS & ASSUMPTIONS ---- | |
# Basic geometry, material properties, loads, factors per ACI 318-19 | |
# Anchor Properties | |
da = 0.75 # Anchor diameter (in) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Flocode Newsletter #062 - Machine Learning for Engineers: When and How Should We Use it? | |
This script demonstrates a simple application of machine learning (ML) to a | |
structural engineering problem: predicting the required depth of a steel beam | |
based on its span and applied uniformly distributed load (UDL). It compares | |
three ML models (linear, non-linear, and deep non-linear neural networks) | |
with a traditional calculation based on the bending moment formula. | |
The key concept is that the ML models are trained on data *derived* from the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This code supports #052 - Python Dictionaries for Engineers | |
# It demonstrates the use of dictionaries, Pandas, and Polars for engineering data handling | |
import pandas as pd | |
import polars as pl | |
from datetime import datetime, timedelta | |
import random | |
# Dictionary storing material attributes | |
steel = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import os | |
import shutil | |
import subprocess | |
import sys | |
from cookiecutter.main import cookiecutter | |
# Template Directory Structure | |
template = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import seaborn as sns | |
import matplotlib.pyplot as plt | |
from scipy.stats import norm | |
# Set the background color to black | |
plt.style.use('dark_background') | |
# Step 1: Define the prior distribution for the remaining fatigue life (in years) | |
prior_mean = 20 # Prior mean fatigue life in years |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ----------------------------------------------------------------------------- | |
# #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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ========================================================== | |
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |