import React, { useState } from 'react';
export const SeismicDiaphragmSheet: React.FC = () => {
// Shared inputs / Constants
const [parallel, setParallel] = useState({
V: 30, // kips
levels: [
{ id: 'Roof', name: 'Roof', cvx: 0.491, wi: 75 }, // Wi from screenshot
{ id: '2', name: '2', cvx: 0.509, wi: 250 },
{ id: '1', name: '1', cvx: 0.000, wi: 0 },
{ id: 'Base', name: 'Base', cvx: 1.000, wi: 0 }, // For sum check
]
});
const [normal, setNormal] = useState({
V: 46, // kips
levels: [
{ id: 'Roof', name: 'Roof', cvx: 0.543, wi: 132 },
{ id: '2', name: '2', cvx: 0.457, wi: 381 },
{ id: '1', name: '1', cvx: 0.000, wi: 0 },
{ id: 'Base', name: 'Base', cvx: 1.000, wi: 0 },
]
});
// Min/Max Factors
const sds = 0.527; // Placeholder or passed prop
const ie = 1.25;
const fpxMinCoeff = 0.2 * sds * ie;
const fpxMaxCoeff = 0.4 * sds * ie;
// Calculation Helper
const calculateTable = (V: number, rows: typeof parallel.levels) => {
return rows.map(r => {
const fx = r.cvx * V; // Fx = Cvx * V
return { ...r, fx };
});
};
// Process Accumulation
const processFpx = (rowsWithFx: any[]) => {
// Need to iterate from Roof down?
// Actually table order is Roof, 2, 1, Base.
// Fpx accumulation logic:
return rowsWithFx.map((r, i) => {
// For accumulated sums, we need to sum from 0 to i?
// Sum(Fi) / Sum(wi)
let sumFi = 0;
let sumWi = 0;
for (let j = 0; j <= i; j++) {
// Assuming rows[0] is Roof (top)
sumFi += rowsWithFx[j].fx;
sumWi += rowsWithFx[j].wi;
}
// Fpx = (sumFi / sumWi) * wpx
// wpx is r.wi
const fpx_calc = sumWi > 0 ? (sumFi / sumWi) * r.wi : 0;
// Check Limits
const fpx_min = fpxMinCoeff * r.wi;
const fpx_max = fpxMaxCoeff * r.wi;
const design_fpx = Math.max(Math.min(fpx_calc, fpx_max), fpx_min);
return { ...r, sumFi, sumWi, fpx: fpx_calc, design: design_fpx };
});
};
const parallelResults = processFpx(calculateTable(parallel.V, parallel.levels));
const normalResults = processFpx(calculateTable(normal.V, normal.levels));
return (
Diaphragm Forces excluding parallel exterior walls
{/* Parallel Table */}
{/* Normal Table */}
User Overrides at each level in addition to above
Parallel to Bldg Length
{/* Placeholder Inputs */}
Adjust ps weight | Adjust wt in kips
Normal to Bldg Length
{/* Placeholder Inputs */}
Adjust psf weight | Adjust wt in kips
);
};