Drop unit suffixes from steel-beam variables and results

Rename calc.py locals and result keys, add inline unit comments, and
normalize Lp/Lr/Lb to feet. Update steel-beam.typ references and the
tests (current W10X15 input, --stdout summary behavior).
This commit is contained in:
smillmorel 2026-09-21 20:11:51 -04:00
commit ddd5ecff58
5 changed files with 129 additions and 133 deletions

View file

@ -99,13 +99,13 @@ def _column_number(reference: str) -> int:
def compute(inp: dict, database: Path = DATABASE) -> dict:
beam_length = quantity(inp["beam_length"], "ft", "beam_length")
unbraced_length = quantity(inp["unbraced_length"], "in", "unbraced_length")
moment_kipft = quantity(inp["Mu"], "kip * ft", "Mu")
shear_kip = quantity(inp["Vu"], "kip", "Vu")
E = quantity(inp["steel_modulus"], "ksi", "steel_modulus")
Fy = quantity(inp["steel_yield"], "ksi", "steel_yield")
service_load = quantity(inp["service_load"], "lbf/ft", "service_load")
beam_length = quantity(inp["beam_length"], "ft", "beam_length") # ft
unbraced_length = quantity(inp["unbraced_length"], "in", "unbraced_length") # in
moment = quantity(inp["Mu"], "kip * ft", "Mu") # kip-ft
shear = quantity(inp["Vu"], "kip", "Vu") # kip
E = quantity(inp["steel_modulus"], "ksi", "steel_modulus") # ksi
Fy = quantity(inp["steel_yield"], "ksi", "steel_yield") # ksi
service_load = quantity(inp["service_load"], "lbf/ft", "service_load") # lbf/ft
Cb = float(inp.get("cb", 1))
c = float(inp.get("c", 1))
if Cb <= 0 or c <= 0:
@ -116,73 +116,73 @@ def compute(inp: dict, database: Path = DATABASE) -> dict:
# the connector (used here as the factored shear). They arrive from the load
# determination, which is based on a uniform gravity load, so the equivalent
# factored uniform load is recovered from the shear: w_u = 2 V_u / L.
factored_uniform_load_kipft = 2.0 * shear_kip / beam_length
factored_uniform_load = 2.0 * shear / beam_length # kip/ft
Lb = unbraced_length
Lp = 1.76 * float(section["ry"]) * math.sqrt(E / Fy)
rts = float(section["rts"])
Sx = float(section["Sx"])
ho = float(section["ho"])
J = float(section["J"])
Lr = 1.95 * rts * E / (0.7 * Fy) * math.sqrt(J * c / (Sx * ho) + math.sqrt((J * c / (Sx * ho)) ** 2 + 6.76 * (0.7 * Fy / E) ** 2))
Fcr = Cb * math.pi**2 * E / (Lb / rts) ** 2 * math.sqrt(1 + 0.078 * J * c / (Sx * ho) * (Lb / rts) ** 2)
Mp = Fy * float(section["Zx"]) / 12.0
Lb = unbraced_length # in
Lp = 1.76 * float(section["ry"]) * math.sqrt(E / Fy) # in
rts = float(section["rts"]) # in
Sx = float(section["Sx"]) # in^3
ho = float(section["ho"]) # in
J = float(section["J"]) # in^4
Lr = 1.95 * rts * E / (0.7 * Fy) * math.sqrt(J * c / (Sx * ho) + math.sqrt((J * c / (Sx * ho)) ** 2 + 6.76 * (0.7 * Fy / E) ** 2)) # in
Fcr = Cb * math.pi**2 * E / (Lb / rts) ** 2 * math.sqrt(1 + 0.078 * J * c / (Sx * ho) * (Lb / rts) ** 2) # ksi
Mp = Fy * float(section["Zx"]) / 12.0 # kip-ft
if Lb <= Lp:
Mn_ltb = Mp
MnLTB = Mp
ltb_mode = "yielding"
elif Lb <= Lr:
Mn_ltb = Cb * (Mp - (Mp - 0.7 * Fy * Sx / 12.0) * (Lb - Lp) / (Lr - Lp))
MnLTB = Cb * (Mp - (Mp - 0.7 * Fy * Sx / 12.0) * (Lb - Lp) / (Lr - Lp))
ltb_mode = "inelastic LTB"
else:
Mn_ltb = Fcr * Sx / 12.0
MnLTB = Fcr * Sx / 12.0
ltb_mode = "elastic LTB"
Mn = min(Mp, Mn_ltb)
phi_mn = 0.9 * Mn
Mn = min(Mp, MnLTB) # kip-ft
phiMn = 0.9 * Mn # kip-ft
Aw = float(section["d"]) * float(section["tw"])
Aw = float(section["d"]) * float(section["tw"]) # in^2
lambda_lim = 2.24 * math.sqrt(E / Fy)
kv = 5.34
lambda_web = float(section["lambda"])
cv1 = 1.0 if lambda_web <= 1.10 * math.sqrt(kv * E / Fy) else 1.10 * math.sqrt(kv * E / Fy) / lambda_web
phi_v = 1.0 if lambda_web <= lambda_lim else 0.9
phi_vn = phi_v * 0.6 * Fy * Aw * cv1
phiVn = phi_v * 0.6 * Fy * Aw * cv1 # kip
# Serviceability deflection under the service uniform load (L/240 limit).
L_in = beam_length * 12.0
w_serv_lbf_in = service_load / 12.0
delta_limit = L_in / 240.0
delta = 5.0 * w_serv_lbf_in * L_in ** 4 / (384.0 * (E * 1000.0) * float(section["Ix"]))
L = beam_length * 12.0 # in
w_service = service_load / 12.0 # lbf/in
delta_limit = L / 240.0 # in
delta = 5.0 * w_service * L ** 4 / (384.0 * (E * 1000.0) * float(section["Ix"])) # in
def q(value: float) -> float:
return round(value, 6)
values = {
"beam_length_ft": q(beam_length),
"unbraced_length_in": q(Lb),
"factored_uniform_load_kipft": q(factored_uniform_load_kipft),
"service_load_lbf_ft": q(service_load),
"moment_kipft": q(moment_kipft),
"shear_kip": q(shear_kip),
"E_ksi": q(E),
"Fy_ksi": q(Fy),
"Lp_in": q(Lp),
"Lr_ft": q(Lr / 12),
"Lb_ft": q(Lb / 12),
"rts_in": q(rts),
"Fcr_ksi": q(Fcr),
"Mp_kipft": q(Mp),
"MnLTB_kipft": q(Mn_ltb),
"Mn_kipft": q(Mn),
"phiMn_kipft": q(phi_mn),
"Aw_in2": q(Aw),
"beam_length": q(beam_length),
"unbraced_length": q(Lb),
"factored_uniform_load": q(factored_uniform_load),
"service_load": q(service_load),
"moment": q(moment),
"shear": q(shear),
"E": q(E),
"Fy": q(Fy),
"Lp": q(Lp / 12),
"Lr": q(Lr / 12),
"Lb": q(Lb / 12),
"rts": q(rts),
"Fcr": q(Fcr),
"Mp": q(Mp),
"MnLTB": q(MnLTB),
"Mn": q(Mn),
"phiMn": q(phiMn),
"Aw": q(Aw),
"lambda": q(lambda_web),
"lambda_lim": q(lambda_lim),
"kv": q(kv),
"Cv1": q(cv1),
"phi_v": q(phi_v),
"phiVn_kip": q(phi_vn),
"delta_limit_in": q(delta_limit),
"delta_in": q(delta),
"phiVn": q(phiVn),
"delta_limit": q(delta_limit),
"delta": q(delta),
"ltb_mode": ltb_mode,
}
values.update({f"section_{key}": q(float(value)) for key, value in section.items() if key != "label"})
@ -194,8 +194,8 @@ def compute(inp: dict, database: Path = DATABASE) -> dict:
"section": section["label"],
"values": values,
"checks": {
"flexure": {"demand": q(moment_kipft), "capacity": q(phi_mn), "ok": moment_kipft <= phi_mn},
"shear": {"demand": q(shear_kip), "capacity": q(phi_vn), "ok": shear_kip <= phi_vn},
"flexure": {"demand": q(moment), "capacity": q(phiMn), "ok": moment <= phiMn},
"shear": {"demand": q(shear), "capacity": q(phiVn), "ok": shear <= phiVn},
"deflection": {"demand": q(delta), "capacity": q(delta_limit), "ok": delta <= delta_limit},
},
}
@ -213,20 +213,20 @@ def summary(result: dict) -> str:
"Steel Beam Design Summary",
f"Project: {result['project']}",
f"Section: {result['section']}",
f"Span: {values['beam_length_ft']:.2f} ft",
f"Span: {values['beam_length']:.2f} ft",
"",
"Demands",
f" Factored moment, Mu: {values['moment_kipft']:.3f} kip-ft",
f" Factored shear, Vu: {values['shear_kip']:.3f} kip",
f" Service load: {values.get('service_load_lbf_ft', 'see input')} lbf/ft",
f" Factored moment, Mu: {values['moment']:.3f} kip-ft",
f" Factored shear, Vu: {values['shear']:.3f} kip",
f" Service load: {values.get('service_load', 'see input')} lbf/ft",
"",
"Strength",
f" Flexure: {status('flexure')} ({values['phiMn_kipft']:.3f} kip-ft capacity, D/C {values['moment_kipft'] / values['phiMn_kipft']:.3f})",
f" Shear: {status('shear')} ({values['phiVn_kip']:.3f} kip capacity, D/C {values['shear_kip'] / values['phiVn_kip']:.3f})",
f" Flexure: {status('flexure')} ({values['phiMn']:.3f} kip-ft capacity, D/C {values['moment'] / values['phiMn']:.3f})",
f" Shear: {status('shear')} ({values['phiVn']:.3f} kip capacity, D/C {values['shear'] / values['phiVn']:.3f})",
f" LTB mode: {values['ltb_mode']}",
"",
"Serviceability",
f" Deflection: {status('deflection')} ({values['delta_in']:.3f} in / {values['delta_limit_in']:.3f} in limit, D/C {values['delta_in'] / values['delta_limit_in']:.3f})",
f" Deflection: {status('deflection')} ({values['delta']:.3f} in / {values['delta_limit']:.3f} in limit, D/C {values['delta'] / values['delta_limit']:.3f})",
]
)