Created
February 23, 2024 16:37
-
-
Save joreilly86/fe82734738888c8323fc9be64f67211d to your computer and use it in GitHub Desktop.
Numpy example from Flocode Newsletter #023 - The Best Python Libraries for Civil/Structural Engineering
This file contains 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 | |
# Print bending stress values | |
print("Bending Stress (N/mm^2) at different y positions (mm):") # Print header | |
for y_val, stress in zip(y, sigma): # Loop through the y values and corresponding stress values | |
print(f"At y = {y_val} mm: {stress:.1f} N/mm^2") # Print stress values to 1 decimal places |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment