Pyton Code For Beam Design
Pyton Code For Beam Design
def calculate_max_moment(self):
# Calculate maximum bending moment (for uniformly distributed
load)
# M = (w * L^2) / 8
return (self.load * self.length ** 2) / 8
def calculate_max_shear(self):
# Calculate maximum shear force
# V = (w * L) / 2
return (self.load * self.length) / 2
def calculate_section_modulus(self):
# Calculate section modulus
# Z = (b * h^2) / 6
return (self.width * self.height ** 2) / 6
def calculate_max_stress(self):
# Calculate maximum bending stress
# σ = M / Z
moment = self.calculate_max_moment() * 1e6 # Convert kNm to
Nmm
section_modulus = self.calculate_section_modulus()
return moment / section_modulus
def main():
# Example usage
length = 6.0 # meters
load = 10.0 # kN/m
width = 300.0 # mm
height = 600.0 # mm
print(f"Beam Properties:")
print(f"Length: {beam.length} m")
print(f"Load: {beam.load} kN/m")
print(f"Cross-section: {beam.width}mm x {beam.height}mm")
print("\nCalculated Results:")
print(f"Maximum Moment: {beam.calculate_max_moment():.2f} kNm")
print(f"Maximum Shear: {beam.calculate_max_shear():.2f} kN")
print(f"Section Modulus: {beam.calculate_section_modulus():.2f}
mm³")
print(f"Maximum Stress: {beam.calculate_max_stress():.2f} N/mm²")
if __name__ == "__main__":
main()
This code:
1. Creates a Beam class with basic properties (length, load, width, height)
2. Includes methods to calculate:
o Maximum bending moment
o Maximum shear force
o Section modulus
o Maximum bending stress
3. Provides a main function with example usage
You can run this code and modify the parameters (length, load, width,
height) to analyze different beam configurations.
Would you like me to explain any specific part of the code or add additional
features like:
Safety factor calculations
Deflection analysis
Different load types
Material properties consideration