/* GeneratorSizer calculators — vanilla JS, no dependencies. Wattage presets use published manufacturer / DOE / consumer-reports ranges, rounded to conservative typical values. All estimates rounded UP to be safe. */ "use strict"; var PRESETS = [ { name:"Refrigerator (Energy Star, 20 cu ft)", run:150, surge:600 }, { name:"Chest freezer (10–15 cu ft)", run:200, surge:600 }, { name:"Well pump — 1/2 HP", run:1000, surge:2100 }, { name:"Well pump — 3/4 HP", run:1500, surge:3000 }, { name:"Sump pump — 1/2 HP", run:800, surge:1300 }, { name:"Window AC — 10,000 BTU", run:900, surge:1400 }, { name:"Central AC — 2.5 ton", run:3500, surge:5000 }, { name:"Furnace fan — 1/3 HP", run:700, surge:1400 }, { name:"Space heater", run:1500, surge:1500 }, { name:"LED lights (whole home)", run:80, surge:80 }, { name:"Microwave (1,000 W)", run:1000, surge:1000 }, { name:"TV + internet + phones", run:150, surge:150 }, { name:"Washing machine", run:1150, surge:2300 }, { name:"Electric water heater", run:4500, surge:4500 }, { name:"Coffee maker", run:1000, surge:1000 }, { name:"Electric skillet / hot plate", run:1200, surge:1200 } ]; // Appliance items the user has added: {name, run, surge, qty} var loads = []; function el(id){ return document.getElementById(id); } function fmt(n){ return Math.round(n).toLocaleString("en-US"); } function ceilTo(n, step){ return Math.ceil(n/step)*step; } /* ---------- Tabs ---------- */ function showTab(key, btn){ document.querySelectorAll(".panel").forEach(function(p){ p.classList.remove("active"); }); document.querySelectorAll(".tabs button").forEach(function(b){ b.setAttribute("aria-selected","false"); }); el(key).classList.add("active"); if(btn) btn.setAttribute("aria-selected","true"); } /* ---------- Load builder ---------- */ function presetOptions(){ var html = ''; PRESETS.forEach(function(p,i){ html += '"; }); html += ''; return html; } function addLoad(name, run, surge){ loads.push({ name:name||"Custom load", run:run||0, surge:surge||0, qty:1 }); renderLoads(); } function renderLoads(){ var wrap = el("loadRows"); if(!loads.length){ wrap.innerHTML = '
No loads yet — pick an appliance above, or add a custom row.
'; } else { var rows = ""; loads.forEach(function(l,i){ rows += 'Running load '+fmt(runTotal)+' W · worst startup surge '+fmt(maxSurge)+' W ('+surgeItem+') · peak demand '+fmt(peak)+' W · +'+Math.round((headroom-1)*100)+'% headroom.
'+ 'Propane delivers ~10% less running wattage than gasoline on dual-fuel models, and propane never goes stale in storage. Runtime figures assume a steady 50% load — real use is cyclical, so expect longer.
'; var box = el("genResult"); box.hidden = false; box.innerHTML = html; } /* ---------- 2. Inverter sizing ---------- */ function sizeInverter(){ var cont = Math.max(0, parseFloat(el("invCont").value) || 0); if(!cont){ alert("Enter your total continuous AC load in watts."); return; } var kind = el("invKind").value; // resistive | motor | compressor | mixed var f = kind === "resistive" ? 1 : kind === "motor" ? 3 : kind === "compressor" ? 4 : 2; var surgeNeed = cont * f; var contRec = ceilTo(cont * 1.25, 100); // 25% headroom on continuous rating var surgeRec = ceilTo(surgeNeed * 1.1, 100); var wireLoss = cont / 0.92 / 12; // approx DC amps drawn at 12V incl. 8% inverter loss var box = el("invResult"); box.hidden = false; box.innerHTML = 'Pure-sine-wave only for electronics, microwaves, and anything with a motor. Modified-sine inverters run hot and can kill compressor motors — the $40 saved is not worth it.
'; } /* ---------- 3. Battery runtime for inverter setups ---------- */ function sizeBatteryRuntime(){ var ah = Math.max(0, parseFloat(el("btAh").value) || 0); var v = parseFloat(el("btV").value) || 12; var w = Math.max(1, parseFloat(el("btLoad").value) || 0); var chem = el("btChem").value; // lifepo4 0.8 | agm 0.5 var dod = chem === "lifepo4" ? 0.80 : 0.50; if(!ah || !w){ alert("Enter battery Ah and load watts."); return; } var usable = ah * v * dod * 0.88; // 88% average inverter efficiency var hrs = usable / w; var cycles = chem === "lifepo4" ? "~3,000" : "~500"; var box = el("btResult"); box.hidden = false; box.innerHTML = 'Batteries deliver less capacity at high draw rates (Peukert effect) — lead-acid especially. If your load is more than C/5 of the bank rating, knock 15% off these hours. Compare fuel costs on the generator sizing page.
'; } /* ---------- 4. Transfer switch load planner ---------- */ function planSwitch(){ var text = el("tsCircuits").value.trim(); if(!text){ alert("List your backup circuits, one per line."); return; } var total = 0, rows = ""; text.split("\n").forEach(function(line){ line = line.trim(); if(!line) return; var m = line.match(/^(.*?)\s*[-–:]\s*([\d,]+)(?:\s*w(?:att)?s?)?\s*$/i); var name = m ? m[1] : line; var w = m ? parseFloat(m[2].replace(/,/g,"")) : 0; total += w; rows += '| Circuit | Watts |
|---|
Fits a '+recTxt+' (switch rating ÷ 1.25 safety must cover your total).
'+ 'Manual switches are ~$400–700 installed; automatic standby transfer switches add $2,000+. A hardwired transfer switch is required by code — never back-feed a dryer outlet.
'; } /* ---------- init ---------- */ document.addEventListener("DOMContentLoaded", function(){ el("presetSelect").innerHTML = presetOptions(); renderLoads(); // preselect a common starter set so the tool shows something useful immediately addLoad(PRESETS[0].name, PRESETS[0].run, PRESETS[0].surge); addLoad(PRESETS[9].name, PRESETS[9].run, PRESETS[9].surge); });