import React, { useState } from 'react'; import { useCalculatorStore } from '../../../store/calculatorStore'; import { ElevatedPlanDiagram, ElevatedElevationDiagram } from './ElevatedBuildingDiagrams'; interface Props { qh: number; G: number; GCpi: number; } export const ElevatedBuildingsSection: React.FC = ({ qh, G, GCpi }) => { const { buildingGeometry, mwfrs } = useCalculatorStore(); // Inputs (Local state as these are specific checks) const [hb, setHb] = useState(0); // Height to bottom const [csaCol, setCsaCol] = useState(64.0); // Cross sectional area of cols const [areaEnc, setAreaEnc] = useState(50.0); // Area of enclosed areas below const [projWidthCol1, setProjWidthCol1] = useState(32.0); const [projWidthEnc1, setProjWidthEnc1] = useState(40.0); const [projWidthCol2, setProjWidthCol2] = useState(30.0); const [projWidthEnc2, setProjWidthEnc2] = useState(42.0); // Derived const L = buildingGeometry.buildingLength; const B = buildingGeometry.leastWidth; const h = mwfrs.userRidgeHeight > 0 ? mwfrs.userRidgeHeight : buildingGeometry.meanRoofHeight; const z = hb + 6.0; // Assume z is strictly related to hb for display // Limitation 1 Calculations const areaAbove = L * B; const totalCsaBelow = csaCol + areaEnc; const areaRatio = areaAbove > 0 ? (totalCsaBelow / areaAbove) : 0; // Limitation 2 Calculations const totalWidth1 = projWidthCol1 + projWidthEnc1; const totalWidth2 = projWidthCol2 + projWidthEnc2; const widthRatio1 = B > 0 ? totalWidth1 / B : 0; const widthRatio2 = L > 0 ? totalWidth2 / L : 0; // Checks // L/B Ratios: const lb1 = B / L; // Direction 1 (Normal) const lb2 = L / B; // Direction 2 (Parallel) const lim2_RatioCheck1 = widthRatio1 < 0.75; const lim2_RatioCheck2 = widthRatio2 < 0.75; const lim2_Pass = lim2_RatioCheck1 && lim2_RatioCheck2; // Vertical Pressures Logic const zones = [ { label: "Downward pressure: 0 to hb/2*", cp: -0.90 }, { label: "hb/2 to hb*", cp: -0.90 }, { label: "hb to 2hb*", cp: -0.50 }, { label: "> 2hb*", cp: -0.30 }, { label: "Upward or min wind pressure", cp: -0.18 } ]; const qi = qh; // Assuming qi = qh for this context const calculateRow = (cp: number) => { const ext = qh * G * cp; // w/ +qiGCpi => External - (+Internal) const netPlus = ext - (qi * Math.abs(GCpi)); // w/ -qiGCpi => External - (-Internal) => External + Internal const netMinus = ext + (qi * Math.abs(GCpi)); return { cp, ext: parseFloat(ext.toFixed(1)), netPlus: parseFloat(netPlus.toFixed(1)), netMinus: parseFloat(netMinus.toFixed(1)) }; }; if (hb === 0) { return (
Elevated Buildings
setHb(parseFloat(e.target.value) || 0)} style={{ width: '60px' }} /> ft
hb = 0, therefore building is not an elevated building
); } return (
Elevated Buildings
{/* Inputs Header */}
setHb(parseFloat(e.target.value) || 0)} style={{ width: '60px', padding: '2px' }} /> ft
{z.toFixed(1)} ft
{/* Limitation 1 Section */}
Horizontal MWFRS wind pressures on objects below hb
Elevated Building Geometry limitation 1
Bldg Length = {L.toFixed(1)} ft
Bldg Width = {B.toFixed(1)} ft
Area of elevated building above = {areaAbove.toFixed(1)} sf
setCsaCol(parseFloat(e.target.value) || 0)} className="input-field" style={{ width: '60px', color: 'red', textAlign: 'right' }} /> sf
setAreaEnc(parseFloat(e.target.value) || 0)} className="input-field" style={{ width: '60px', color: 'red', textAlign: 'right' }} /> sf
Total cross sectional area below bldg = {totalCsaBelow.toFixed(1)} sf

Area of below elements / Area of Bldg above = {(areaRatio * 100).toFixed(1)}%
Direction 1 L/B = {lb1.toFixed(2)}    Max L/B = 0.500 {(lb1 <= 0.5) ? 'OK' : 'NG'}
Direction 2 L/B = {lb2.toFixed(2)}    Max L/B = 0.500 {(lb2 <= 0.5) ? 'OK' : 'OK'}
Meets geometry Limitation No 1 for both directions
{/* Limitation 2 Section */}
Elevated Building Geometry limitation 2
{/* Dir 1 */}
Direction 1
setProjWidthCol1(parseFloat(e.target.value) || 0)} className="input-field" style={{ width: '50px', color: 'red' }} /> ft
setProjWidthEnc1(parseFloat(e.target.value) || 0)} className="input-field" style={{ width: '50px', color: 'red' }} /> ft
Total projected width below bldg (width) = {totalWidth1.toFixed(1)} ft
Projected area ratio = {(widthRatio1 * 100).toFixed(1)}% {lim2_RatioCheck1 ? '. 75% OK' : '> 75% NG'}
{/* Dir 2 */}
Direction 2
setProjWidthCol2(parseFloat(e.target.value) || 0)} className="input-field" style={{ width: '50px', color: 'red' }} /> ft
setProjWidthEnc2(parseFloat(e.target.value) || 0)} className="input-field" style={{ width: '50px', color: 'red' }} /> ft
Total projected width below bldg (width) = {totalWidth2.toFixed(1)} ft
Projected area ratio = {(widthRatio2 * 100).toFixed(1)}% {lim2_RatioCheck2 ? '. 75% OK' : '> 75% NG'}
{lim2_Pass ? "Meets geometry Limitation No 2 for both directions" : "Doesn't meet geometry Limitation No 2 for either direction"}
hb = {hb} ft, therefore building {lim2_Pass ? "is" : "is"} an elevated building
{/* Vertical Pressures Table */}
Vertical MWFRS wind pressures on bottom surface of the elevated building
Base pressure (Kd qz) = {(0.85 * qh).toFixed(1)} psf
Ultimate Vertical MWFRS Wind Surface Pressures (psf) at horizontal bottom surface
{/* Normal Cols */} {/* Parallel Cols */} {zones.map((zone, i) => { const res = calculateRow(zone.cp); return ( {/* Normal */} {/* Parallel (Identical logic) */} ); })}
Wind Normal to Ridge Wind Parallel to Ridge
L/B = {(B / L).toFixed(2)}    hb/L = {B > 0 ? (hb / B).toFixed(2) : '0.00'} L/B = {(L / B).toFixed(2)}    hb/L = {L > 0 ? (hb / L).toFixed(2) : '0.00'}
Dist.* Cp q_h GCp w/ +qiGCpi w/ -qiGCpi Dist.* Cp q_h GCp w/ +qiGCpi w/ -qiGCpi
{zone.label}{res.cp.toFixed(2)} {res.ext.toFixed(1)} {res.netPlus.toFixed(1)} {res.netMinus.toFixed(1)}{zone.label.replace('Downward pressure: ', '')} {res.cp.toFixed(2)} {res.ext.toFixed(1)} {res.netPlus.toFixed(1)} {res.netMinus.toFixed(1)}
); };