# Pythonコード:構造解析(片持ちはり + 集中荷重)
# =======================================================
# 2025-03-24
# 梁の構造計算プログラム / Beam Structural Calculation
# =======================================================
# -------------------------------------------------------
# 【Step 1】梁の種類を選択 / Select Beam Type
# -------------------------------------------------------
print("【Step1】梁の種類を選択 / Select Beam Type")
beam_type = "片持ち梁 + 集中荷重 / Cantilever Beam with Point Load"
print("選択された梁:", beam_type)
print()
# ------------------------------
# Step 2: 断面の種類を選択 / Cross-section Type
# ------------------------------
print("【Step2】断面の種類を選択 / Select Cross-section Type")
section_type = "四角形 / Rectangular"
print("断面形状:", section_type)
print()
# ------------------------------
# Step 3: 材料を選択 / Material
# ------------------------------
print("【Step3】材料を選択します / Select Material")
material = "Fe(鉄 / Iron)"
E = 205000 # MPa
density = 7.86e-6 # kg/mm^3
print("材質:", material)
print("ヤング率 E:", E, "MPa")
print("密度 ρ:", density, "kg/mm³")
print()
# ------------------------------
# Step 4: 入力値 / Input Values
# ------------------------------
print("【Step4】各数値を代入します / Input Beam and Section Info")
L = 200 # mm
F = 200 # N
F_kgf = F / 9.80665 # kgfに変換(参考値)
b = 20 # mm
h = 30 # mm
print("↓はりの情報 / Beam Info")
print("はりの長さ L:", L, "mm")
print("荷重 F:", F, "N (", round(F_kgf, 3), "kgf )")
print()
print("↓断面の情報 / Cross-section Info")
print("幅 b:", b, "mm")
print("高さ h:", h, "mm")
# ------------------------------
# 断面特性の計算 / Section Properties
# ------------------------------
A = b * h # mm^2
I = (b * h**3) / 12 # mm^4
Z = (b * h**2) / 6 # mm^3
print()
print("↓断面の計算結果 / Calculated Section Properties")
print("断面積 A = b × h =", A, "mm²")
print("断面二次モーメント I = (b × h³) / 12 =", I, "mm⁴")
print("断面係数 Z = (b × h²) / 6 =", Z, "mm³")
print()
# ------------------------------
# 荷重によるたわみ δ1 / Deflection by Load
# ------------------------------
δ1 = (F * L**3) / (3 * E * I) # mm
# 自重による荷重 w = ρ × g × A
g = 9.80665 # m/s²
w = density * g * A # N/mm
δ2 = (w * L**4) / (8 * E * I) # mm
δ_total = δ1 + δ2
# 応力
σ = (F * L) / Z # MPa
# 重量
volume = A * L # mm³
mass = volume * density # kg
weight_kgf = mass * g / 9.80665 # kgf
# ------------------------------
# 結果の表示 / Display Results
# ------------------------------
print("【計算式】")
print("・たわみ量:")
print(" δ1 = (F×L³)/(3×E×I) =", round(δ1, 3), "mm")
print(" δ2 = (w×L⁴)/(8×E×I) =", round(δ2, 3), "mm (w = {:.4f} N/mm)".format(w))
print(" δ = δ1 + δ2 =", round(δ_total, 3), "mm")
print("・応力:")
print(" σ = (F×L)/Z =", round(σ, 3), "MPa")
print()
print("■計算結果:たわみ量 / Deflection")
print("荷重によるたわみ δ1:", round(δ1, 3), "mm")
print("自重によるたわみ δ2:", round(δ2, 3), "mm")
print("たわみ合計 δ:", round(δ_total, 3), "mm")
print()
print("■計算結果:応力 / Stress")
print("最大応力 σ:", round(σ, 3), "MPa")
print()
print("■計算結果:重量 / Weight")
print("はりの重量:", round(weight_kgf, 3), "kgf")