beams / utils /plot_utils.py
sikandarciv101's picture
Update utils/plot_utils.py
3d434e7 verified
# utils/plot_utils.py
import matplotlib.pyplot as plt
import numpy as np
def plot_beam_shape(span_lengths, supports, load_type):
fig, ax = plt.subplots(figsize=(10, 2))
ax.plot([0, sum(span_lengths)], [0, 0], color='black', lw=4)
current_position = 0
for i, length in enumerate(span_lengths):
ax.plot([current_position + length, current_position + length], [0, 1], color='blue', lw=2)
current_position += length
for i, support in enumerate(supports):
ax.text(i * 10, 0.5, support, ha='center', fontsize=12)
ax.set_title("Beam Shape")
ax.axis('off')
plt.show()
def plot_sfd(shear_forces, span_lengths):
fig, ax = plt.subplots(figsize=(10, 6))
x = np.linspace(0, sum(span_lengths), len(shear_forces))
y = shear_forces
ax.plot(x, y, label='Shear Force', color='red', lw=2)
ax.set_title("Shear Force Diagram (SFD)")
ax.set_xlabel("Beam Length (ft)")
ax.set_ylabel("Shear Force (kN)")
ax.grid(True)
plt.show()
def plot_bmd(bending_moments, span_lengths):
fig, ax = plt.subplots(figsize=(10, 6))
x = np.linspace(0, sum(span_lengths), len(bending_moments))
y = bending_moments
ax.plot(x, y, label='Bending Moment', color='blue', lw=2)
ax.set_title("Bending Moment Diagram (BMD)")
ax.set_xlabel("Beam Length (ft)")
ax.set_ylabel("Bending Moment (kNm)")
ax.grid(True)
plt.show()