import React, { useState } from 'react'; import { LeewardDriftDiagram, SlidingSnowDiagram } from '../diagrams/SnowDriftDiagrams2'; export const SnowLoadsSheet2: React.FC = () => { // Inputs: High Roof vs Lower Roof const [highRoof, setHighRoof] = useState({ slopeDeg: 0.4, W: 11.9, L: 50.4, roofType: 'Hip and gable w/ trussed systems', }); const [lowRoof, setLowRoof] = useState({ slopeDeg: 2.4, // 0.5/12 W: 78.0, L: 121.0, stepH: 5.0, // Projection height (roof step) h separation: 0.0, roofType: 'Hip and gable w/ trussed systems', }); // Shared / Other inputs const [common, setCommon] = useState({ Pg: 21.0, risk: 'III', Ce: 1.0, Ct: 1.188, snowFactor: 1.0, R: 30, W2: 0.35, }); // Constants const Is = common.risk === 'I' ? 0.8 : common.risk === 'II' ? 1.0 : common.risk === 'III' ? 1.1 : 1.2; const snowDensity = Math.min(30, 0.13 * common.Pg + 14); // --- High Roof Calculations --- const Pf_High = 0.7 * common.Ce * common.Ct * Is * common.Pg; const Cs_High = 1.0; // Simplified const Ps_High = Cs_High * Pf_High; const Pm_High = common.Pg <= 20 ? Is * common.Pg : Is * 20; const Design_High = Math.max(Ps_High, Pm_High); // Simplified // --- Lower Roof Calculations --- const Pf_Low = 0.7 * common.Ce * common.Ct * Is * common.Pg; const Cs_Low = 1.0; // Simplified const Ps_Low = Cs_Low * Pf_Low; const Pm_Low = common.Pg <= 20 ? Is * common.Pg : Is * 20; const Design_Low = Math.max(Ps_Low, Pm_Low); // Simplified // --- Drift Calculations --- // Helper const calculateDrift = (lu: number, h: number, pf: number) => { if (lu <= 0) return { hd: 0, w: 0, pd: 0, hc: 0, hb: 0, driftReq: false, msg: '' }; const hb = pf / snowDensity; // drift height hd const hd_calc = 0.43 * Math.pow(lu, 1 / 3) * Math.pow(common.Pg + 10, 0.25) - 1.5; const hd = Math.max(0, hd_calc); // hc = h - hb const hc = h - hb; // Ratio check const ratio = hb > 0 ? hc / hb : 100; let driftReq = true; let msg = ''; if (ratio < 0.2) { driftReq = false; msg = `hc/hb < 0.2 (${ratio.toFixed(1)})`; } if (hc <= 0) { driftReq = false; msg = 'hc <= 0'; } const design_hd = Math.min(hd, hc); const w = 4 * design_hd; const pd = snowDensity * design_hd; return { hd: design_hd, w, pd, hc, hb, driftReq, msg, ratio }; }; const [driftInputs, setDriftInputs] = useState({ lu_leeward: 123.0, lu_windward: 78.0, }); const leewardResults = calculateDrift(driftInputs.lu_leeward, lowRoof.stepH, Pf_Low); // Correcting windward calc with 0.75 factor const calculateWindwardDrift = (lu: number, h: number, pf: number) => { const res = calculateDrift(lu, h, pf); const hd_windward = res.hd * 0.75; // Windward factor // Re-check constraints with windward hd const design_hd = Math.min(hd_windward, res.hc); const w = 4 * design_hd; const pd = snowDensity * design_hd; return { ...res, hd: design_hd, w, pd }; }; const windwardFinal = calculateWindwardDrift(driftInputs.lu_windward, lowRoof.stepH, Pf_Low); // --- Sliding Snow --- const slopeThreshold = 1.19; // approx 1/4 on 12 const slidingReq = highRoof.slopeDeg > slopeThreshold; const slidingLoad = slidingReq ? 0.4 * Pf_High * highRoof.W : 0; const slidingPressure = slidingReq ? slidingLoad / 15 : 0; return (