GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Solar and storage design / globalgrid2050 / solar-bess-topology-v5

GIS Single-Line Diagram (SLD) V5 Calculations and 6 more files

A JavaScript file in GlobalGrid2050 that works with transformers and cables. Served with the page at https://globalgrid2050.com/solar-bess-topology-v5/.

659 lines of JavaScript and HTML from globalgrid2050, in 7 files. Topic: Solar and storage design. Section 85 of 2044.

Cut 2026-12-06T03:07:51+00:00. A copy for reading; the repository at the stated commit is the source.

In the State lines below, domain stage, users and canonical status are rule-based first approximations from code and path evidence (rules explore-agent-rules-v1), not observed facts: the rules.

In this section

  1. DC AC LV Topology Review V5 render · globalgrid2050 / solar-bess-topology-v5/dc-ac-lv-topology-review-v5.html lines 1–117
  2. DC AC LV Topology Review V5 interaction · globalgrid2050 / solar-bess-topology-v5/dc-ac-lv-topology-review-v5.js lines 1–162
  3. GIS Single-Line Diagram (SLD) V4 Config electrical · globalgrid2050 / solar-bess-topology-v5/gis-sld-v4-config.js lines 1–24
  4. GIS Single-Line Diagram (SLD) V4 Helpers geodesy · globalgrid2050 / solar-bess-topology-v5/gis-sld-v4-helpers.js lines 1–75
  5. GIS Single-Line Diagram (SLD) V4 State electrical · globalgrid2050 / solar-bess-topology-v5/gis-sld-v4-state.js lines 1–28
  6. GIS Single-Line Diagram (SLD) V4 Substations electrical · globalgrid2050 / solar-bess-topology-v5/gis-sld-v4-substations.js lines 1–83
  7. GIS Single-Line Diagram (SLD) V5 Calculations electrical · globalgrid2050 / solar-bess-topology-v5/gis-sld-v5-calculations.js lines 1–170

DC AC LV Topology Review V5

A web page in GlobalGrid2050 that draws SVG graphics and reads inputs for mod wp, voc and vmp (units: MVA, °C, MW). Published at https://globalgrid2050.com/solar-bess-topology-v5/dc-ac-lv-topology-review-v5.html.

Set aside from the main view: 92% of its lines are the same as solar-bess-topology-v5/install_dc_ac_lv_01_html.py (globalgrid2050), which stays. (near-copy-of, proposed by families.py). 91% of lines shared with Install DC AC LV 01 HTML; read that one first. All set-aside files, with reasons. Nothing was deleted.

Evidence
  • line-jaccard 0.9151 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-bess-topology-v5/install_dc_ac_lv_01_html.py:1-126 b6cfc6e6950e4984eae545899fc6f8cb994622f0
  • sha256 d7e25a596b2ccc1d3c1bda0e7bfdf5f1d60d452991d274a112bd1bf03fe43086
  • target sha256 8c0958e45095c4d51a043735d721d6ecf7f15db43309bbf46b702d5ad9195d2e
  • group of 2 (identity.json near-copy edges >= 0.9)
  • canonical rule: reachable, newest stamp, core repo, most lines

renderglobalgrid2050 / solar-bess-topology-v5/dc-ac-lv-topology-review-v5.html · lines 1–117 of 117 · Entry point

What it does
It draws cables, 33kV, solar and transformers. Side effects: changes the web page (DOM).
Why it exists in the grid workflow
Domain stage sub33kv_design (path word 'ac'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary. Domain terms in the code: cables, 33kV, solar, transformers.
Inputs & outputs
In: form fields (user input). Out: web page; SVG drawing. Voltage levels named: 33kV.
Downstream impact
Used directly by 2 files: Cable Geometry Visualiser V5 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v5/cable-geometry-visualiser-v5.html); Module Layout V5 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v5/module-layout-v5.html). Reached from 99 other entry points, including GlobalGrid2050 Historical Builds (globalgrid2050, https://globalgrid2050.com/historical_builds.html); GlobalGrid2050 Homepage Before Four Nests (globalgrid2050, https://globalgrid2050.com/homepage-before-four-nests-20260925.html); Homepage V037 (globalgrid2050, https://globalgrid2050.com/homepage_versions/homepage_v037.html). It is itself an entry point, published at https://globalgrid2050.com/solar-bess-topology-v5/dc-ac-lv-topology-review-v5.html.
What it achieves
Its code works with 33 kV and 0 MVA.
Why it matters
Loaded by the Cable Geometry Visualiser V5 page at https://globalgrid2050.com/solar-bess-topology-v5/cable-geometry-visualiser-v5.html and 1 other page.
Application
globalgrid2050 · solar-bess-topology-v5 · page
Uses
GIS Single-Line Diagram (SLD) V4 (stylesheet), Module Layout V5 (stylesheet), DC AC LV Topology Review V5 (stylesheet), Module Layout V5 (link), Indexforgis Single-Line Diagram (SLD) V5 (link), DC AC LV Topology Review V5 (script src)
Used by
linked from Cable Geometry Visualiser V5 (link), linked from Module Layout V5 (link)
Produces
none declared
Defines here
none
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-bess-topology-v5/dc-ac-lv-topology-review-v5.html:1-117 · blob f570da3b90499d7181be643e14f1044620eacf8d · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>DC AC LV Topology Review V5 | GlobalGrid2050</title>
    <link rel="stylesheet" href="./gis-sld-v5.css" />
    <link rel="stylesheet" href="./module-layout-v5.css" />
    <link rel="stylesheet" href="./dc-ac-lv-topology-review-v5.css" />
</head>
<body>
    <div class="module-app-shell topo-app-shell">
        <header class="module-header topo-header">
            <div>
                <div class="module-kicker">GlobalGrid2050 V5</div>
                <h1>DC AC LV Topology Review</h1>
                <p>Separate low voltage and DC engineering app for solar PV cable topology, string sizing, inverter aggregation, skid loading and SCADA style topology review.</p>
            </div>
            <div class="topo-header-links">
                <a class="module-link" href="./module-layout-v5.html">Module Layout V5</a>
                <a class="module-link" href="./indexforgis-sld-v5.html">Back to GIS SLD V5</a>
            </div>
        </header>

        <main class="module-main topo-main">
            <section class="module-panel topo-panel">
                <div class="topo-tabs">
                    <button id="topo_tab_string" class="topo-tab active" data-mode="string">String Inverter</button>
                    <button id="topo_tab_central" class="topo-tab" data-mode="central">Central Inverter</button>
                </div>

                <div class="topo-mode active" data-mode-panel="string">
                    <h2>Module Electrical Data</h2>
                    <label>Module Rating Wp</label><input id="s_mod_wp" type="number" value="660" step="1" />
                    <label>Module Voc V</label><input id="s_voc" type="number" value="45.9" step="0.01" />
                    <label>Module Vmp V</label><input id="s_vmp" type="number" value="38.1" step="0.01" />
                    <label>Module Isc A</label><input id="s_isc" type="number" value="18.45" step="0.01" />
                    <label>Module Imp A</label><input id="s_imp" type="number" value="17.35" step="0.01" />
                    <label>Maximum Series Fuse A</label><input id="s_fuse_a" type="number" value="35" step="1" />
                    <label>Maximum System Voltage Vdc</label><input id="s_system_v" type="number" value="1500" step="10" />
                    <label>Voc Temperature Coefficient % per °C</label><input id="s_voc_coeff" type="number" value="-0.25" step="0.01" />
                    <label>Isc Temperature Coefficient % per °C</label><input id="s_isc_coeff" type="number" value="0.04" step="0.01" />
                    <label>Minimum Design Temperature °C</label><input id="s_min_temp" type="number" value="-10" step="1" />
                    <label>Current Correction Factor</label><input id="s_current_factor" type="number" value="1.25" step="0.01" />
                    <label>Bifacial Current Uplift %</label><input id="s_bifacial_current" type="number" value="10" step="1" />

                    <h2>String Inverter Topology</h2>
                    <label>Modules per String</label><input id="s_modules_per_string" type="number" value="30" min="1" step="1" />
                    <label>Strings per String Inverter</label><input id="s_strings_per_inverter" type="number" value="21" min="1" step="1" />
                    <label>String Inverter Rating kVA</label><input id="s_inverter_kva" type="number" value="352" min="1" step="1" />
                    <label>String Inverters per Skid</label><input id="s_inverters_per_skid" type="number" value="28" min="1" step="1" />
                    <label>Skid Transformer Rating MVA</label><input id="s_skid_mva" type="number" value="8.96" min="0.1" step="0.01" />
                    <label>Skids per 33 kV Ring</label><input id="s_skids_per_ring" type="number" value="5" min="1" step="1" />

                    <h2>DC Cable Review</h2>
                    <label>DC String Cable Length m</label><input id="s_dc_length_m" type="number" value="300" min="1" step="1" />
                    <label>DC Cable CSA mm²</label><input id="s_dc_csa" type="number" value="6" min="1" step="1" />
                    <label>DC Cable Material</label><select id="s_dc_material"><option value="cu" selected>Copper</option><option value="al">Aluminium</option></select>
                    <label>Allowable DC Voltage Drop %</label><input id="s_dc_vdrop_limit" type="number" value="1.0" step="0.1" />
                </div>

                <div class="topo-mode" data-mode-panel="central">
                    <h2>Module Electrical Data</h2>
                    <label>Module Rating Wp</label><input id="c_mod_wp" type="number" value="660" step="1" />
                    <label>Module Voc V</label><input id="c_voc" type="number" value="45.9" step="0.01" />
                    <label>Module Vmp V</label><input id="c_vmp" type="number" value="38.1" step="0.01" />
                    <label>Module Isc A</label><input id="c_isc" type="number" value="18.45" step="0.01" />
                    <label>Maximum System Voltage Vdc</label><input id="c_system_v" type="number" value="1500" step="10" />
                    <label>Voc Temperature Coefficient % per °C</label><input id="c_voc_coeff" type="number" value="-0.25" step="0.01" />
                    <label>Minimum Design Temperature °C</label><input id="c_min_temp" type="number" value="-10" step="1" />
                    <label>Current Correction Factor</label><input id="c_current_factor" type="number" value="1.25" step="0.01" />
                    <label>Bifacial Current Uplift %</label><input id="c_bifacial_current" type="number" value="10" step="1" />

                    <h2>Central Inverter Topology</h2>
                    <label>Modules per String</label><input id="c_modules_per_string" type="number" value="30" min="1" step="1" />
                    <label>Strings per Combiner Box</label><input id="c_strings_per_combiner" type="number" value="24" min="1" step="1" />
                    <label>Combiner Box Design Limit kWdc</label><input id="c_combiner_limit_kw" type="number" value="500" min="1" step="10" />
                    <label>Central Inverter DC Input Rating MWdc</label><input id="c_inv_dc_mw" type="number" value="5.28" min="0.1" step="0.01" />
                    <label>Central Inverter AC Output Rating MWac</label><input id="c_inv_ac_mw" type="number" value="4.40" min="0.1" step="0.01" />
                    <label>Central Skid Transformer Rating MVA</label><input id="c_skid_mva" type="number" value="4.40" min="0.1" step="0.01" />
                    <label>Central Inverter Units per Skid</label><input id="c_inverters_per_skid" type="number" value="1" min="1" step="1" />
                    <label>Central Skids per 33 kV Ring</label><input id="c_skids_per_ring" type="number" value="5" min="1" step="1" />

                    <h2>DC Cable Review</h2>
                    <label>Home Run Cable Length m</label><input id="c_dc_length_m" type="number" value="300" min="1" step="1" />
                    <label>DC Cable CSA mm²</label><input id="c_dc_csa" type="number" value="6" min="1" step="1" />
                    <label>DC Cable Material</label><select id="c_dc_material"><option value="cu" selected>Copper</option><option value="al">Aluminium</option></select>
                    <label>Allowable DC Voltage Drop %</label><input id="c_dc_vdrop_limit" type="number" value="1.0" step="0.1" />
                </div>

                <h2>Topology Results</h2>
                <div class="module-stat"><span>String kWp</span><strong id="out_string_kwp">0</strong></div>
                <div class="module-stat"><span>String Vmp</span><strong id="out_string_vmp">0 V</strong></div>
                <div class="module-stat"><span>String Voc STC</span><strong id="out_string_voc_stc">0 V</strong></div>
                <div class="module-stat"><span>Cold String Voc</span><strong id="out_string_voc_cold">0 V</strong></div>
                <div class="module-stat"><span>Max Modules per String</span><strong id="out_max_modules">0</strong></div>
                <div class="module-stat"><span>Design String Current</span><strong id="out_design_current">0 A</strong></div>
                <div class="module-stat"><span>DC per Inverter</span><strong id="out_dc_per_inv">0 kWp</strong></div>
                <div class="module-stat"><span>Inverter DC/AC</span><strong id="out_dcac">0</strong></div>
                <div class="module-stat"><span>Skid DC / AC</span><strong id="out_skid_block">0</strong></div>
                <div class="module-stat"><span>Ring AC Rating</span><strong id="out_ring_ac">0 MVA</strong></div>
                <div class="module-stat"><span>DC Cable Loss</span><strong id="out_dc_loss">0%</strong></div>
                <div id="topo_status" class="module-status">Ready.</div>

                <div class="module-note">Screening tool only. It does not replace manufacturer checks, cable schedules, load flow, fault studies, insulation coordination, SPD coordination, protection grading, earthing design or IFC drawings.</div>
            </section>

            <section class="topo-scada-card">
                <div class="topo-scada-title">SCADA Style Cable Topology Panel</div>
                <svg id="topo_scada" viewBox="0 0 1200 760" role="img" aria-label="SCADA style topology drawing"></svg>
                <div class="topo-scada-footer"><span id="topo_footer_left">String inverter topology</span><span>Values recalculate live from left panel</span></div>
            </section>
        </main>
    </div>
    <script src="./dc-ac-lv-topology-review-v5.js?v=stable-live-update-1"></script>
</body>
</html>

DC AC LV Topology Review V5

A JavaScript file in GlobalGrid2050 that calculates central (`calcCentral`) and renders stats (`renderStats`) and scada (`renderScada`) (units: MVA, MW, kW). Served with the page at https://globalgrid2050.com/solar-bess-topology-v5/.

Set aside from the main view: 95% of its lines are the same as solar-bess-topology-v5/install_dc_ac_lv_03_js.py (globalgrid2050), which stays. (near-copy-of, proposed by families.py). 94% of lines shared with Install DC AC LV 03 JS; read that one first. All set-aside files, with reasons. Nothing was deleted.

Evidence
  • line-jaccard 0.9496 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-bess-topology-v5/install_dc_ac_lv_03_js.py:1-171 5c3894f8eaf868eddd100bc3c74787673543ba5f
  • sha256 51268a64cb57b1bfa63552906456512136c9fc0b1e13f40f127beb3f43544f96
  • target sha256 e75743aff63b6857b2ad18f50e211e27846074e8c128bc20d99151fa314f9589
  • group of 2 (identity.json near-copy edges >= 0.9)
  • canonical rule: reachable, newest stamp, core repo, most lines

interactionglobalgrid2050 / solar-bess-topology-v5/dc-ac-lv-topology-review-v5.js · lines 1–162 of 162 · Entry point · pattern svgEl (shared by 2 files)

What it does
It draws transformers and cables. Defines 18 functions or classes, including t, n, i, txt, fmt. Side effects: changes the web page (DOM).
Why it exists in the grid workflow
Domain stage sub33kv_design (path word 'ac'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary. Domain terms in the code: transformers, cables, 33kV.
Inputs & outputs
Out: SVG drawing. Voltage levels named: 33kV.
Downstream impact
Used directly by 3 files: DC AC LV Topology Review V5 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v5/dc-ac-lv-topology-review-v5.html); Solar Battery Energy Storage System (BESS) Topology V6 — DC AC LV Topology Review Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v6/dc-ac-lv-topology-review/); Solar Battery Energy Storage System (BESS) Topology V7 — DC AC LV Topology Review Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v7/dc-ac-lv-topology-review/). Reached from 156 other entry points, including Iterations — 43 Registry Growth Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/43-registry-growth/); Iterations — 47 Federation Honesty Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/47-federation-honesty/); Cable Geometry Visualiser V5 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v5/cable-geometry-visualiser-v5.html). It is itself an entry point, published at https://globalgrid2050.com/solar-bess-topology-v5/.
What it achieves
It renders stats (`renderStats`), renders scada (`renderScada`) and sets mode (`setMode`). Defines `txt`, `fmt`, `read` and 12 more. Its code works with 33 kV. It responds to input, change and click events.
Why it matters
Loaded by the page of the same name at https://globalgrid2050.com/solar-bess-topology-v5/dc-ac-lv-topology-review-v5.html and 2 other pages.
Application
globalgrid2050 · solar-bess-topology-v5 · script
Uses
none found
Used by
loaded by DC AC LV Topology Review V5 (script src), loaded by Solar Battery Energy Storage System (BESS) Topology V6 — DC AC LV Topology Review Page (script src), loaded by Solar Battery Energy Storage System (BESS) Topology V7 — DC AC LV Topology Review Page (script src)
Produces
t, n, i, txt, fmt, read, baseCalc, calcString, calcCentral, currentCalc, renderStats, svgEl
Defines here
t, n, i, txt, fmt, read, baseCalc, calcString, calcCentral, currentCalc, renderStats, svgEl, box, line, renderScada, update, setMode, boot
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-bess-topology-v5/dc-ac-lv-topology-review-v5.js:1-162 · blob f9d13da499112dc3838e98d3525fb0a22f9dd01f · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
"use strict";

const topoState = { mode: "string" };
const RHO = { cu: 0.01724, al: 0.02826 };

function t(id) { return document.getElementById(id); }
function n(id, fallback = 0) { const el = t(id); if (!el) return fallback; const v = parseFloat(el.value); return Number.isFinite(v) ? v : fallback; }
function i(id, fallback = 0) { return Math.max(0, Math.round(n(id, fallback))); }
function txt(id, value) { const el = t(id); if (el) el.textContent = value; }
function fmt(v, d = 2) { return Number.isFinite(v) ? v.toFixed(d) : "0.00"; }

function read(prefix) {
    return {
        modWp: n(prefix + "_mod_wp", 660),
        voc: n(prefix + "_voc", 45.9),
        vmp: n(prefix + "_vmp", 38.1),
        isc: n(prefix + "_isc", 18.45),
        imp: n(prefix + "_imp", 17.35),
        fuseA: n(prefix + "_fuse_a", 35),
        systemV: n(prefix + "_system_v", 1500),
        vocCoeff: n(prefix + "_voc_coeff", -0.25),
        iscCoeff: n(prefix + "_isc_coeff", 0.04),
        minTemp: n(prefix + "_min_temp", -10),
        currentFactor: n(prefix + "_current_factor", 1.25),
        bifacialCurrent: n(prefix + "_bifacial_current", 10),
        modulesPerString: i(prefix + "_modules_per_string", 30),
        dcLengthM: n(prefix + "_dc_length_m", 300),
        dcCsa: n(prefix + "_dc_csa", 6),
        dcMaterial: t(prefix + "_dc_material")?.value || "cu",
        dcVdropLimit: n(prefix + "_dc_vdrop_limit", 1)
    };
}

function baseCalc(v) {
    const stringKwp = v.modulesPerString * v.modWp / 1000;
    const stringVmp = v.modulesPerString * v.vmp;
    const stringVocStc = v.modulesPerString * v.voc;
    const coldFactor = 1 + Math.abs(v.vocCoeff / 100) * (25 - v.minTemp);
    const coldModuleVoc = v.voc * coldFactor;
    const coldStringVoc = v.modulesPerString * coldModuleVoc;
    const maxModules = Math.floor(v.systemV / coldModuleVoc);
    const designCurrent = v.isc * v.currentFactor * (1 + v.bifacialCurrent / 100);
    const rho = RHO[v.dcMaterial] || RHO.cu;
    const loopResistance = 2 * v.dcLengthM * rho / v.dcCsa;
    const cableDropV = designCurrent * loopResistance;
    const cableDropPct = stringVmp > 0 ? cableDropV / stringVmp * 100 : 0;
    const cableLossW = designCurrent * designCurrent * loopResistance;
    return { stringKwp, stringVmp, stringVocStc, coldFactor, coldStringVoc, maxModules, designCurrent, loopResistance, cableDropV, cableDropPct, cableLossW };
}

function calcString() {
    const v = read("s");
    v.stringsPerInverter = i("s_strings_per_inverter", 21);
    v.inverterKva = n("s_inverter_kva", 352);
    v.invertersPerSkid = i("s_inverters_per_skid", 28);
    v.skidMva = n("s_skid_mva", 8.96);
    v.skidsPerRing = i("s_skids_per_ring", 5);
    const b = baseCalc(v);
    const dcPerInvKwp = b.stringKwp * v.stringsPerInverter;
    const invAcMva = v.inverterKva / 1000;
    const dcac = invAcMva > 0 ? dcPerInvKwp / 1000 / invAcMva : 0;
    const skidDcMwp = dcPerInvKwp * v.invertersPerSkid / 1000;
    const skidInvAcMva = invAcMva * v.invertersPerSkid;
    const ringAcMva = v.skidMva * v.skidsPerRing;
    const warnings = [];
    if (b.coldStringVoc > v.systemV) warnings.push("Cold string Voc exceeds system voltage limit");
    if (v.modulesPerString > b.maxModules) warnings.push("Modules per string exceeds calculated cold limit");
    if (b.designCurrent > v.fuseA * 0.8) warnings.push("Design current approaches module fuse rating");
    if (b.cableDropPct > v.dcVdropLimit) warnings.push("DC cable voltage drop exceeds selected limit");
    if (skidInvAcMva > v.skidMva) warnings.push("Inverter ACmax exceeds selected skid transformer rating");
    return { mode: "string", v, b, dcPerInvKwp, invAcMva, dcac, skidDcMwp, skidInvAcMva, ringAcMva, warnings };
}

function calcCentral() {
    const v = read("c");
    v.stringsPerCombiner = i("c_strings_per_combiner", 24);
    v.combinerLimitKw = n("c_combiner_limit_kw", 500);
    v.invDcMw = n("c_inv_dc_mw", 5.28);
    v.invAcMw = n("c_inv_ac_mw", 4.40);
    v.skidMva = n("c_skid_mva", 4.40);
    v.invertersPerSkid = i("c_inverters_per_skid", 1);
    v.skidsPerRing = i("c_skids_per_ring", 5);
    const b = baseCalc(v);
    const combinerKw = b.stringKwp * v.stringsPerCombiner;
    const reqStrings = Math.ceil(v.invDcMw * 1000 / b.stringKwp);
    const combinersPerInv = Math.ceil(reqStrings / v.stringsPerCombiner);
    const dcac = v.invAcMw > 0 ? v.invDcMw / v.invAcMw : 0;
    const skidDcMwp = v.invDcMw * v.invertersPerSkid;
    const skidInvAcMva = v.invAcMw * v.invertersPerSkid;
    const ringAcMva = v.skidMva * v.skidsPerRing;
    const warnings = [];
    if (b.coldStringVoc > v.systemV) warnings.push("Cold string Voc exceeds system voltage limit");
    if (combinerKw > v.combinerLimitKw) warnings.push("Combiner box DC capacity exceeds selected limit");
    if (b.cableDropPct > v.dcVdropLimit) warnings.push("DC cable voltage drop exceeds selected limit");
    if (v.invAcMw > v.skidMva) warnings.push("Central AC output exceeds selected skid transformer rating");
    return { mode: "central", v, b, combinerKw, reqStrings, combinersPerInv, dcPerInvKwp: v.invDcMw * 1000, invAcMva: v.invAcMw, dcac, skidDcMwp, skidInvAcMva, ringAcMva, warnings };
}

function currentCalc() { return topoState.mode === "central" ? calcCentral() : calcString(); }

function renderStats(r) {
    txt("out_string_kwp", fmt(r.b.stringKwp, 2) + " kWp");
    txt("out_string_vmp", fmt(r.b.stringVmp, 1) + " V");
    txt("out_string_voc_stc", fmt(r.b.stringVocStc, 1) + " V");
    txt("out_string_voc_cold", fmt(r.b.coldStringVoc, 1) + " V");
    txt("out_max_modules", String(r.b.maxModules));
    txt("out_design_current", fmt(r.b.designCurrent, 2) + " A");
    txt("out_dc_per_inv", fmt(r.dcPerInvKwp, 1) + " kWp");
    txt("out_dcac", fmt(r.dcac, 3));
    txt("out_skid_block", fmt(r.skidDcMwp, 2) + " MWp / " + fmt(r.skidInvAcMva, 2) + " MVA");
    txt("out_ring_ac", fmt(r.ringAcMva, 2) + " MVA");
    txt("out_dc_loss", fmt(r.b.cableDropPct, 2) + "% / " + fmt(r.b.cableLossW, 0) + " W");
    txt("topo_status", r.warnings.length ? r.warnings.join(" | ") : "No screening warnings from current assumptions.");
}

function svgEl(name, attrs = {}, text = null) {
    const el = document.createElementNS("http://www.w3.org/2000/svg", name);
    Object.entries(attrs).forEach(([k, v]) => el.setAttribute(k, v));
    if (text !== null) el.textContent = text;
    return el;
}

function box(svg, x, y, w, h, title, lines = [], tone = "") {
    svg.appendChild(svgEl("rect", { x, y, width: w, height: h, class: "scada-box " + tone, rx: 10 }));
    svg.appendChild(svgEl("text", { x: x + 14, y: y + 28, class: "scada-text" }, title));
    lines.forEach((line, idx) => svg.appendChild(svgEl("text", { x: x + 14, y: y + 55 + idx * 20, class: idx === 0 ? "scada-value" : "scada-small" }, line)));
}

function line(svg, x1, y1, x2, y2, tone = "") { svg.appendChild(svgEl("path", { d: `M ${x1} ${y1} L ${x2} ${y2}`, class: "scada-line " + tone })); }

function renderScada(r) {
    const svg = t("topo_scada");
    if (!svg) return;
    svg.innerHTML = "";
    svg.appendChild(svgEl("text", { x: 32, y: 56, class: "scada-text" }, r.mode === "string" ? "STRING INVERTER TOPOLOGY" : "CENTRAL INVERTER TOPOLOGY"));
    const warnTone = r.warnings.length ? "orange" : "green";
    if (r.mode === "string") {
        box(svg, 60, 110, 190, 110, "PV Module", [`${fmt(r.v.modWp,0)} Wp`, `Voc ${fmt(r.v.voc,1)} V`, `Isc ${fmt(r.v.isc,2)} A`], "green");
        box(svg, 310, 110, 210, 110, "String", [`${r.v.modulesPerString} modules`, `${fmt(r.b.stringKwp,2)} kWp`, `Cold Voc ${fmt(r.b.coldStringVoc,1)} V`], warnTone);
        box(svg, 585, 110, 230, 110, "String Inverter", [`${r.v.stringsPerInverter} strings`, `${fmt(r.dcPerInvKwp,1)} kWp DC`, `${fmt(r.invAcMva,3)} MVA AC`]);
        box(svg, 880, 110, 230, 110, "Skid", [`${r.v.invertersPerSkid} inverters`, `${fmt(r.skidDcMwp,2)} MWp`, `${fmt(r.v.skidMva,2)} MVA transformer`], warnTone);
        box(svg, 460, 350, 280, 115, "33 kV Ring", [`${r.v.skidsPerRing} skids`, `${fmt(r.ringAcMva,2)} MVA`, `Screening view only`], "orange");
        line(svg, 250, 165, 310, 165, "green"); line(svg, 520, 165, 585, 165); line(svg, 815, 165, 880, 165); line(svg, 995, 220, 600, 350, "orange");
    } else {
        box(svg, 60, 110, 190, 110, "PV Module", [`${fmt(r.v.modWp,0)} Wp`, `Voc ${fmt(r.v.voc,1)} V`, `Isc ${fmt(r.v.isc,2)} A`], "green");
        box(svg, 290, 110, 190, 110, "String", [`${r.v.modulesPerString} modules`, `${fmt(r.b.stringKwp,2)} kWp`, `I ${fmt(r.b.designCurrent,1)} A`], warnTone);
        box(svg, 530, 110, 220, 110, "Combiner", [`${r.v.stringsPerCombiner} strings`, `${fmt(r.combinerKw,1)} kWdc`, `${r.combinersPerInv} per inverter`], warnTone);
        box(svg, 800, 110, 260, 110, "Central Inverter", [`${fmt(r.v.invDcMw,2)} MWdc input`, `${fmt(r.v.invAcMw,2)} MWac output`, `DC/AC ${fmt(r.dcac,2)}`], "orange");
        box(svg, 460, 350, 280, 115, "Skid and Ring", [`Skid ${fmt(r.v.skidMva,2)} MVA`, `${r.v.skidsPerRing} skids per ring`, `Ring ${fmt(r.ringAcMva,2)} MVA`]);
        line(svg, 250, 165, 290, 165, "green"); line(svg, 480, 165, 530, 165); line(svg, 750, 165, 800, 165, "orange"); line(svg, 930, 220, 600, 350, "orange");
    }
    const y = 560;
    svg.appendChild(svgEl("text", { x: 60, y, class: "scada-warning" }, r.warnings.length ? "WARNINGS" : "STATUS"));
    if (r.warnings.length) r.warnings.slice(0, 5).forEach((w, idx) => svg.appendChild(svgEl("text", { x: 60, y: y + 28 + idx * 22, class: "scada-warning" }, "• " + w)));
    else svg.appendChild(svgEl("text", { x: 60, y: y + 28, class: "scada-value" }, "No screening warnings. Verify with full engineering studies before design use."));
    txt("topo_footer_left", r.mode === "string" ? "String inverter LV and DC chain" : "Central inverter combiner and skid chain");
}

function update() { const r = currentCalc(); renderStats(r); renderScada(r); }
function setMode(mode) { topoState.mode = mode; document.querySelectorAll(".topo-tab").forEach(b => b.classList.toggle("active", b.dataset.mode === mode)); document.querySelectorAll(".topo-mode").forEach(p => p.classList.toggle("active", p.dataset.modePanel === mode)); update(); }
function boot() { document.querySelectorAll("input, select").forEach(el => { el.addEventListener("input", update); el.addEventListener("change", update); }); document.querySelectorAll(".topo-tab").forEach(btn => btn.addEventListener("click", () => setMode(btn.dataset.mode))); update(); }
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", boot); else boot();

GIS Single-Line Diagram (SLD) V4 Config

A JavaScript file in GlobalGrid2050 covering grid substations. Served with the page at https://globalgrid2050.com/solar-bess-topology-v5/.

Set aside from the main view: 90% of its lines are the same as feature_requests/002_extract_v2_config/files/solar-bess-topology-v2/gis-sld-v2-config.js (globalgrid2050), which stays. (near-copy-of, proposed by families.py). 90% of lines shared with GIS Single-Line Diagram (SLD) V5 Config; read that one first. All set-aside files, with reasons. Nothing was deleted.

Evidence
  • line-jaccard 0.9 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 feature_requests/002_extract_v2_config/files/solar-bess-topology-v2/gis-sld-v2-config.js:1-24 16f6bd9326da4b37595e2387875688de764ea254
  • sha256 9351a4ce1459fdd090fd97505d38aeff10acbd5402521864d42110334c19f14e
  • target sha256 65b623d4bf62135a3f36e5c0ead7648018db95602b369dfb519cc19542ab22c6
  • group of 8 (identity.json near-copy edges >= 0.9)
  • canonical rule: reachable, newest stamp, core repo, most lines
  • re-pointed by apply.py version rule from file 133 to file 254; similarity was measured to file 133

electricalglobalgrid2050 / solar-bess-topology-v5/gis-sld-v4-config.js · lines 1–24 of 24 · Entry point

Why it exists in the grid workflow
Domain stage sub33kv_design (path word 'bess'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary.
Downstream impact
Used directly by 2 files: Indexforgis Single-Line Diagram (SLD) V5 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v5/indexforgis-sld-v5.html); Module Layout V5 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v5/module-layout-v5.html). Reached from 102 other entry points, including Cable Geometry Visualiser V5 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v5/cable-geometry-visualiser-v5.html); DC AC LV Topology Review V5 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v5/dc-ac-lv-topology-review-v5.html); GlobalGrid2050 Historical Builds (globalgrid2050, https://globalgrid2050.com/historical_builds.html). It is itself an entry point, published at https://globalgrid2050.com/solar-bess-topology-v5/.
What it achieves
GIS SLD Financial Sandbox V5. Config extracted by GridBot feature 002.
Why it matters
Loaded by the Indexforgis Single-Line Diagram (SLD) V5 page at https://globalgrid2050.com/solar-bess-topology-v5/indexforgis-sld-v5.html and 1 other page.
Application
globalgrid2050 · solar-bess-topology-v5 · script
Uses
none found
Used by
loaded by Indexforgis Single-Line Diagram (SLD) V5 (script src), loaded by Module Layout V5 (script src)
Produces
none declared
Defines here
none
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-bess-topology-v5/gis-sld-v4-config.js:1-24 · blob 67c5adefb5465a34d2fa0066a75adc249451d420 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: unknown · effects: none found · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
"use strict";

// GIS SLD Financial Sandbox V5
// Config extracted by GridBot feature 002.
// TODO: migrate config into the shared GISSLD namespace at feature 007.

const SUBSTATIONS_URL = "/grid_substations.geojson";

const CONSTANTS = {
    M2_PER_ACRE: 4046.86,
    BESS_M2_PER_MWH: 85,
    BESS_ASPECT: 2.5,
    BLOCK_SPACING_KM: 0.01,
    BOUNDARY_BUFFER_KM: 0.02,
    ARRAY_OFFSET_KM: 0.2,
    DEFAULT_CENTER: [-0.1276, 51.5072],
    DEFAULT_ZOOM: 13,
    RECALC_DEBOUNCE_MS: 80,
    BIFACIAL_BY_GCR: { "0.35": 8, "0.45": 5, "0.75": 2 },
    LOGISTICS_PRESETS: {
        high_density: { pallet: 33, container: 594 },
        legacy: { pallet: 31, container: 620 }
    }
};

GIS Single-Line Diagram (SLD) V4 Helpers

A JavaScript file in GlobalGrid2050 that sets class (`setClass`), picks prop (`pickProp`) and sets fetch status (`setFetchStatus`). Served with the page at https://globalgrid2050.com/solar-bess-topology-v5/.

Set aside from the main view: 91% of its lines are the same as feature_requests/003_extract_v2_helpers/files/solar-bess-topology-v2/gis-sld-v2-helpers.js (globalgrid2050), which stays. (near-copy-of, proposed by families.py). 91% of lines shared with GIS Single-Line Diagram (SLD) V5 Helpers; read that one first. All set-aside files, with reasons. Nothing was deleted.

Evidence
  • line-jaccard 0.913 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 feature_requests/003_extract_v2_helpers/files/solar-bess-topology-v2/gis-sld-v2-helpers.js:1-75 3fe3702efbfab7b20e83e2e2f8113e55b3da2324
  • sha256 85764ec159463f60935d8048d9419670cb9298ea848eb13053b5bf21babaef0c
  • target sha256 ecacdadc1dcdda92a551a0ec31344c4b9cb96958f8e35bf92a2896355fdd49b6
  • group of 6 (identity.json near-copy edges >= 0.9)
  • canonical rule: reachable, newest stamp, core repo, most lines
  • re-pointed by apply.py version rule from file 134 to file 256; similarity was measured to file 134

geodesyglobalgrid2050 / solar-bess-topology-v5/gis-sld-v4-helpers.js · lines 1–75 of 75 · Entry point · pattern setFetchStatus (shared by 7 files)

What it does
Defines 11 functions or classes, including $, num, intVal, checked, setText. Side effects: changes the web page (DOM).
Why it exists in the grid workflow
Domain stage sub33kv_design (path word 'bess'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary.
Downstream impact
Used directly by 2 files: Indexforgis Single-Line Diagram (SLD) V5 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v5/indexforgis-sld-v5.html); Module Layout V5 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v5/module-layout-v5.html). Reached from 102 other entry points, including Cable Geometry Visualiser V5 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v5/cable-geometry-visualiser-v5.html); DC AC LV Topology Review V5 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v5/dc-ac-lv-topology-review-v5.html); GlobalGrid2050 Historical Builds (globalgrid2050, https://globalgrid2050.com/historical_builds.html). It is itself an entry point, published at https://globalgrid2050.com/solar-bess-topology-v5/.
What it achieves
It sets text (`setText`), sets class (`setClass`) and picks prop (`pickProp`). GIS SLD Financial Sandbox V5. Helpers extracted by GridBot feature 003.
Why it matters
Loaded by the Indexforgis Single-Line Diagram (SLD) V5 page at https://globalgrid2050.com/solar-bess-topology-v5/indexforgis-sld-v5.html and 1 other page.
Application
globalgrid2050 · solar-bess-topology-v5 · script
Uses
none found
Used by
loaded by Indexforgis Single-Line Diagram (SLD) V5 (script src), loaded by Module Layout V5 (script src)
Produces
$, num, intVal, checked, setText, setClass, money, debounce, isValidLngLat, pickProp, setFetchStatus
Defines here
$, num, intVal, checked, setText, setClass, money, debounce, isValidLngLat, pickProp, setFetchStatus
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-bess-topology-v5/gis-sld-v4-helpers.js:1-75 · blob 2103455c5b25ea85799b2f4a1dc86e8e783013ce · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
"use strict";

// GIS SLD Financial Sandbox V5
// Helpers extracted by GridBot feature 003.
// Must load after gis-sld-v5-config.js and before the inline app script.

const $ = (id) => document.getElementById(id);

const num = (id) => {
    const el = $(id);
    return el ? (parseFloat(el.value) || 0) : 0;
};

const intVal = (id, fallback = 0) => {
    const el = $(id);
    return el ? (parseInt(el.value, 10) || fallback) : fallback;
};

const checked = (id) => {
    const el = $(id);
    return el ? !!el.checked : false;
};

const setText = (id, val) => {
    const el = $(id);
    if (el) el.textContent = val;
};

const setClass = (id, cls) => {
    const el = $(id);
    if (el) el.className = cls;
};

function money(v) {
    const rounded = Math.round(v);
    if (rounded < 0) return "-£" + Math.abs(rounded).toLocaleString();
    return "£" + rounded.toLocaleString();
}

function debounce(fn, ms) {
    let t = null;
    return function(...args) {
        clearTimeout(t);
        t = setTimeout(() => fn.apply(this, args), ms);
    };
}

function isValidLngLat(c) {
    return Array.isArray(c) && c.length >= 2
        && Number.isFinite(+c[0]) && Number.isFinite(+c[1])
        && +c[0] >= -180 && +c[0] <= 180 && +c[1] >= -90 && +c[1] <= 90;
}

function pickProp(obj, keys, fallback = null) {
    for (const k of keys) {
        if (obj && obj[k] !== undefined && obj[k] !== null && obj[k] !== "") return obj[k];
    }
    return fallback;
}

function setFetchStatus(msg, isError) {
    const el = $("fetch_status");
    if (!el) return;

    if (!msg) {
        el.style.display = "none";
        el.textContent = "";
        el.classList.remove("error");
        return;
    }

    el.textContent = msg;
    el.style.display = "block";
    el.classList.toggle("error", !!isError);
}

GIS Single-Line Diagram (SLD) V4 State

A JavaScript file in GlobalGrid2050. Served with the page at https://globalgrid2050.com/solar-bess-topology-v5/.

electricalglobalgrid2050 / solar-bess-topology-v5/gis-sld-v4-state.js · lines 1–28 of 28 · Entry point

Why it exists in the grid workflow
Domain stage sub33kv_design (path word 'bess'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary.
Downstream impact
Used directly by 1 file: Indexforgis Single-Line Diagram (SLD) V5 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v5/indexforgis-sld-v5.html). Reached from 103 other entry points, including Cable Geometry Visualiser V5 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v5/cable-geometry-visualiser-v5.html); DC AC LV Topology Review V5 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v5/dc-ac-lv-topology-review-v5.html); GlobalGrid2050 Historical Builds (globalgrid2050, https://globalgrid2050.com/historical_builds.html). It is itself an entry point, published at https://globalgrid2050.com/solar-bess-topology-v5/.
What it achieves
GIS SLD Financial Sandbox V5. State extracted by GridBot feature 004.
Why it matters
Loaded by the Indexforgis Single-Line Diagram (SLD) V5 page at https://globalgrid2050.com/solar-bess-topology-v5/indexforgis-sld-v5.html.
Application
globalgrid2050 · solar-bess-topology-v5 · script
Uses
none found
Used by
loaded by Indexforgis Single-Line Diagram (SLD) V5 (script src)
Produces
none declared
Defines here
none
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-bess-topology-v5/gis-sld-v4-state.js:1-28 · blob 2740a8fa076888b5a529c5aa0975d0e5b72b652f · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: unknown · effects: none found · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
"use strict";

// GIS SLD Financial Sandbox V5
// State extracted by GridBot feature 004.
// Must load after config and helpers, and before the inline app script.

const state = {
    activeTab: "string",
    currentGeoJSON: { type: "FeatureCollection", features: [] },
    activeDrawCenter: null,
    selectedSubstation: null,
    subsVisible: true,
    satActive: false,
    activePopup: null,
    lastStats: null,
    lastFinance: { fin_string: null, fin_central: null },
    arrayMoveMode: false,
    arrayOverrideCenter: null,
    arrayRotationDeg: 0,
    exportCableLengthKm: 0,
    cableRoutePinMode: false,
    cableRoutePins: [],
    cableRouteCommitted: false,
    suppressNextMapFit: false,
    // Legacy aliases retained for older export and drawing logic if needed.
    cableRouteMode: false,
    cableRouteWaypoints: []
};

GIS Single-Line Diagram (SLD) V4 Substations

A JavaScript file in GlobalGrid2050 that fetches substations. Served with the page at https://globalgrid2050.com/solar-bess-topology-v5/. It normalises substations (`normaliseSubstations`) and loads substations (`loadSubstations`).

Set aside from the main view: 96% of its lines are the same as feature_requests/005_extract_v2_substation_data/files/solar-bess-topology-v2/gis-sld-v2-substations.js (globalgrid2050), which stays. (near-copy-of, proposed by families.py). 96% of lines shared with GIS Single-Line Diagram (SLD) V5 Substations; read that one first. All set-aside files, with reasons. Nothing was deleted.

Evidence
  • line-jaccard 0.9643 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 feature_requests/005_extract_v2_substation_data/files/solar-bess-topology-v2/gis-sld-v2-substations.js:1-83 914c0ad9fd2b1b3006858ad3b20e5d328252e85d
  • sha256 06cee623168ca208cdf38f4e5fabda01d3cee4c826bd3c8f7b8070f1fbca81bd
  • target sha256 f73fc672ab0d11720a53279d0663d6f2ad9f525d3aa0535608aa7031a72e9c41
  • group of 6 (identity.json near-copy edges >= 0.9)
  • canonical rule: reachable, newest stamp, core repo, most lines
  • re-pointed by apply.py version rule from file 136 to file 259; similarity was measured to file 136

electricalglobalgrid2050 / solar-bess-topology-v5/gis-sld-v4-substations.js · lines 1–83 of 83 · Entry point · pattern normaliseSubstations (shared by 7 files)

What it does
It fetches substations. Defines normaliseSubstations, loadSubstations. Side effects: makes network requests.
Why it exists in the grid workflow
Domain stage sub33kv_design (path word 'bess'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary. Domain terms in the code: substations.
Downstream impact
Used directly by 1 file: Indexforgis Single-Line Diagram (SLD) V5 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v5/indexforgis-sld-v5.html). Reached from 103 other entry points, including Cable Geometry Visualiser V5 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v5/cable-geometry-visualiser-v5.html); DC AC LV Topology Review V5 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v5/dc-ac-lv-topology-review-v5.html); GlobalGrid2050 Historical Builds (globalgrid2050, https://globalgrid2050.com/historical_builds.html). It is itself an entry point, published at https://globalgrid2050.com/solar-bess-topology-v5/.
What it achieves
GIS SLD Financial Sandbox V5. Substation data loading extracted by GridBot feature 005.
Why it matters
Loaded by the Indexforgis Single-Line Diagram (SLD) V5 page at https://globalgrid2050.com/solar-bess-topology-v5/indexforgis-sld-v5.html.
Application
globalgrid2050 · solar-bess-topology-v5 · script
Uses
none found
Used by
loaded by Indexforgis Single-Line Diagram (SLD) V5 (script src)
Produces
normaliseSubstations, loadSubstations
Defines here
normaliseSubstations, loadSubstations
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-bess-topology-v5/gis-sld-v4-substations.js:1-83 · blob 022706c7060f6cfa2309c1dba9f775ced9922886 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: ingest · effects: network · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
"use strict";

// GIS SLD Financial Sandbox V5
// Substation data loading extracted by GridBot feature 005.
// Must load after config, helpers and state, and before the inline app script.

function normaliseSubstations(raw) {
    if (!raw) throw new Error("Empty dataset");

    let features = [];

    if (raw.type === "FeatureCollection" && Array.isArray(raw.features)) {
        features = raw.features;
    } else if (Array.isArray(raw)) {
        features = raw.map(item => ({
            type: "Feature",
            geometry: item.geometry || {
                type: "Point",
                coordinates: [
                    item.lon ?? item.lng ?? item.longitude ?? item.Longitude ?? item.X,
                    item.lat ?? item.latitude ?? item.Latitude ?? item.Y
                ]
            },
            properties: item.properties || item
        }));
    } else {
        throw new Error("Not a FeatureCollection or array");
    }

    const cleaned = features
        .filter(f => f && f.geometry && f.geometry.type === "Point")
        .map(f => {
            const c = f.geometry.coordinates.map(Number);
            if (!isValidLngLat(c)) return null;

            const p = f.properties || {};

            return {
                type: "Feature",
                geometry: { type: "Point", coordinates: [c[0], c[1]] },
                properties: {
                    ...p,
                    name_clean: pickProp(
                        p,
                        ["name", "Name", "site_name", "SiteName", "Site Name", "substation", "Substation", "substation_name", "Substation Name"],
                        "Substation"
                    ),
                    voltage_clean: pickProp(
                        p,
                        ["voltage", "Voltage", "kv", "kV", "KV", "voltage_kv", "Voltage kV"],
                        "Unknown"
                    )
                }
            };
        })
        .filter(Boolean);

    return { type: "FeatureCollection", features: cleaned };
}

async function loadSubstations() {
    setFetchStatus("Loading substations…", false);

    try {
        const url = SUBSTATIONS_URL + (SUBSTATIONS_URL.includes("?") ? "&" : "?") + "v=" + Date.now();
        const res = await fetch(url);

        if (!res.ok) throw new Error("HTTP " + res.status);

        const raw = await res.json();
        const cleaned = normaliseSubstations(raw);
        const src = map.getSource("src-subs");

        if (src) src.setData(cleaned);

        console.log("Substations loaded:", cleaned.features.length);
        setFetchStatus(`${cleaned.features.length.toLocaleString()} substations loaded`, false);
        setTimeout(() => setFetchStatus("", false), 2500);
    } catch (err) {
        console.error("Substation load failed:", err);
        setFetchStatus(`Substations unavailable: ${err.message}. Check SUBSTATIONS_URL.`, true);
    }
}

GIS Single-Line Diagram (SLD) V5 Calculations

A JavaScript file in GlobalGrid2050 that works with transformers and cables. Served with the page at https://globalgrid2050.com/solar-bess-topology-v5/.

electricalglobalgrid2050 / solar-bess-topology-v5/gis-sld-v5-calculations.js · lines 1–170 of 170 · Entry point · pattern computeCentralStats (shared by 4 files)

What it does
It calculates transformers and cables. Defines 9 functions or classes, including readPhysicalInputs, zeroStats, buildStats, getCentralInverterMwac, getCentralInverterDcMwdc.
Why it exists in the grid workflow
Domain stage sub33kv_design (path word 'bess'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary. Domain terms in the code: transformers, cables.
Downstream impact
Used directly by 7 files: Indexforgis Single-Line Diagram (SLD) V5 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v5/indexforgis-sld-v5.html); Solar Battery Energy Storage System (BESS) Topology V6 — GIS Single-Line Diagram (SLD) Financial Sandbox Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v6/gis-sld-financial-sandbox/); Solar Battery Energy Storage System (BESS) Topology V7 — GIS Single-Line Diagram (SLD) Financial Sandbox Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v7/gis-sld-financial-sandbox/); Solar Battery Energy Storage System (BESS) Topology V7 — GIS Single-Line Diagram (SLD) Financial Sandbox Page (globalgrid2050, https://globalgrid2050.com/testcode/202609052011/layer-apps/solar-bess-topology-v7/gis-sld-financial-sandbox/); and 3 more. Reached from 165 other entry points, including Iterations — 43 Registry Growth Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/43-registry-growth/); Iterations — 47 Federation Honesty Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/47-federation-honesty/); Cable Geometry Visualiser V5 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v5/cable-geometry-visualiser-v5.html). It is itself an entry point, published at https://globalgrid2050.com/solar-bess-topology-v5/.
What it achieves
It reads physical inputs (`readPhysicalInputs`), builds stats (`buildStats`) and gets central inverter mwac (`getCentralInverterMwac`). AGGREGATE STATS (single unified function).
Why it matters
Loaded by the Indexforgis Single-Line Diagram (SLD) V5 page at https://globalgrid2050.com/solar-bess-topology-v5/indexforgis-sld-v5.html and 5 other pages. Also imported by Build Graph, from Ventus Grid Engine.
Application
globalgrid2050 · solar-bess-topology-v5 · script
Uses
none found
Used by
loaded by Indexforgis Single-Line Diagram (SLD) V5 (script src), loaded by Solar Battery Energy Storage System (BESS) Topology V6 — GIS Single-Line Diagram (SLD) Financial Sandbox Page (script src), loaded by Solar Battery Energy Storage System (BESS) Topology V7 — GIS Single-Line Diagram (SLD) Financial Sandbox Page (script src), loaded by Solar Battery Energy Storage System (BESS) Topology V7 — GIS Single-Line Diagram (SLD) Financial Sandbox Page (script src), loaded by Solar Battery Energy Storage System (BESS) Topology V7 — GIS Single-Line Diagram (SLD) Financial Sandbox Page (script src), named by URL in Build Graph (estate URL), named by URL in Ventus Grid Engine — Genome Page (estate URL), mentioned in Standalone (comment link)
Produces
readPhysicalInputs, zeroStats, buildStats, getCentralInverterMwac, getCentralInverterDcMwdc, getCentralSkidMva, computeStringStats, computeCentralStats, computeStats
Defines here
readPhysicalInputs, zeroStats, buildStats, getCentralInverterMwac, getCentralInverterDcMwdc, getCentralSkidMva, computeStringStats, computeCentralStats, computeStats
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-bess-topology-v5/gis-sld-v5-calculations.js:1-170 · blob 7787553ccd9d8b5c49b165760bfc4b8c6168450c · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
"use strict";

// AGGREGATE STATS  (single unified function)
// ============================================================
function readPhysicalInputs(suffix) {
    return {
        mod_wp: num("mod_wp" + suffix),
        mod_l: num("mod_l" + suffix),
        mod_w: num("mod_w" + suffix),
        gcr: parseFloat($("mounting_type" + suffix)?.value) || (suffix === "_c" ? 0.45 : 0.75),
        gross_factor: num("gross_factor" + suffix) || 1.35,
        mods_pallet: intVal("mods_pallet" + suffix, 1),
        mods_container: intVal("mods_container" + suffix, 1),
        spare_pct: num("spare_pct" + suffix)
    };
}

function zeroStats(dc_ac_ratio, mods_pallet, mods_container) {
    return {
        total_blocks: 0, block_ground_area_m2: 0, dc_mwp: 0, ac_mw: 0, module_count: 0,
        net_mod_area_m2: 0, net_array_area_m2: 0, gross_site_area_m2: 0,
        dc_ac_ratio, pallets: 0, containers: 0, spares_pct: 0,
        modules_inc_spares: 0, pallets_inc_spares: 0, containers_inc_spares: 0,
        mods_pallet, mods_container,
        combiner_boxes_per_inverter: 0, total_combiner_boxes: 0,
        string_inverter_kva: 0, production_substation_ac_mva: 0, ring_main_ac_mva: 0,
        central_inverter_mwac: 0, combiner_box_dc_kw: 0, combiner_design_limit_kwdc: 0,
        engineering_warning: "Check assumptions"
    };
}

function buildStats(opts) {
    const {
        total_blocks, module_count, ac_mw_direct, dc_ac_ratio, physical,
        combiner_boxes_per_inverter, total_combiner_boxes,
        string_inverter_kva, inverter_acmax_mva, production_substation_ac_mva, ring_main_ac_mva,
        central_inverter_mwac, central_inverter_mwdc, combiner_box_dc_kw, combiner_design_limit_kwdc,
        engineering_warning
    } = opts;
    const { mod_wp, mod_l, mod_w, gcr, gross_factor, mods_pallet, mods_container, spare_pct } = physical;

    const dc_mwp = (module_count * mod_wp) / 1_000_000;
    const ac_mw = ac_mw_direct != null ? ac_mw_direct : (dc_ac_ratio > 0 ? dc_mwp / dc_ac_ratio : 0);
    const actual_dc_ac = ac_mw > 0 ? dc_mwp / ac_mw : dc_ac_ratio;

    const net_mod_area_m2 = module_count * mod_l * mod_w;
    const net_array_area_m2 = gcr > 0 ? net_mod_area_m2 / gcr : 0;
    const gross_site_area_m2 = net_array_area_m2 * gross_factor;
    const block_ground_area_m2 = total_blocks > 0 ? net_array_area_m2 / total_blocks : 0;

    const pallets = Math.ceil(module_count / mods_pallet);
    const containers = Math.ceil(module_count / mods_container);
    const modules_inc_spares = Math.ceil(module_count * (1 + spare_pct / 100));
    const pallets_inc_spares = Math.ceil(modules_inc_spares / mods_pallet);
    const containers_inc_spares = Math.ceil(modules_inc_spares / mods_container);

    return {
        total_blocks, block_ground_area_m2, dc_mwp, ac_mw, module_count,
        net_mod_area_m2, net_array_area_m2, gross_site_area_m2, dc_ac_ratio: actual_dc_ac,
        pallets, containers, spares_pct: spare_pct,
        modules_inc_spares, pallets_inc_spares, containers_inc_spares,
        mods_pallet, mods_container,
        combiner_boxes_per_inverter: combiner_boxes_per_inverter || 0,
        total_combiner_boxes: total_combiner_boxes || 0,
        string_inverter_kva: string_inverter_kva || 0,
        inverter_acmax_mva: inverter_acmax_mva || 0,
        production_substation_ac_mva: production_substation_ac_mva || 0,
        ring_main_ac_mva: ring_main_ac_mva || 0,
        central_inverter_mwac: central_inverter_mwac || 0,
        central_inverter_mwdc: central_inverter_mwdc || 0,
        combiner_box_dc_kw: combiner_box_dc_kw || 0,
        combiner_design_limit_kwdc: combiner_design_limit_kwdc || 0,
        engineering_warning: engineering_warning || "Check assumptions"
    };
}

function getCentralInverterMwac() {
    const mode = $("central_rating_mode")?.value || "preset";
    const preset = num("inv_ac_mw_c") || 4.4;
    const customRaw = num("inv_ac_mw_custom_c") || preset;
    const custom = Math.min(Math.max(customRaw, 0.1), 20);
    return mode === "custom" ? custom : preset;
}

function getCentralInverterDcMwdc() {
    const dc = num("inv_dc_mw_c") || ((num("inv_ac_mw_c") || 4.4) * 1.2);
    return Math.min(Math.max(dc, 0.1), 30);
}

function getCentralSkidMva() {
    const mva = num("central_skid_mva_c") || (num("inv_ac_mw_c") || 4.4);
    return Math.min(Math.max(mva, 0.1), 25);
}

function computeStringStats() {
    const physical = readPhysicalInputs("");
    const x = intVal("x_mods"), z = intVal("z_strings"), y = intVal("y_invs"), s = intVal("s_subs"), rings = intVal("b_cols");
    const dc_ac_ratio = num("dc_ac_ratio") || 1.2;
    const string_inverter_kva = num("string_inv_kva") || 352;
    const string_skid_mva = num("string_skid_mva") || 8.96;

    if (physical.mod_wp <= 0 || physical.mod_l <= 0 || physical.mod_w <= 0 || x <= 0) {
        return zeroStats(dc_ac_ratio, physical.mods_pallet, physical.mods_container);
    }

    const total_blocks = rings * s;
    const module_count = total_blocks * y * z * x;
    const inverter_acmax_mva = (y * string_inverter_kva) / 1000;
    const production_substation_ac_mva = string_skid_mva;
    const ring_main_ac_mva = production_substation_ac_mva * s;
    const ac_mw_direct = total_blocks * production_substation_ac_mva;
    let engineering_warning = "Check skid rating, transformer rating, cable ratings, protection, losses and grid compliance.";
    if (inverter_acmax_mva > production_substation_ac_mva) engineering_warning = "Inverter ACmax exceeds skid transformer rating. Verify temperature rating, overload strategy and clipping assumptions.";
    if (string_inverter_kva > 500) engineering_warning = "Large string inverter rating selected. Verify LV switchgear, transformer, cable loading and protection.";

    return buildStats({
        total_blocks, module_count, ac_mw_direct, dc_ac_ratio, physical,
        string_inverter_kva, inverter_acmax_mva, production_substation_ac_mva, ring_main_ac_mva,
        engineering_warning
    });
}

function computeCentralStats() {
    const physical = readPhysicalInputs("_c");
    const x_mods = intVal("x_mods_c");
    const inv_ac_mw = getCentralInverterMwac();
    const inv_dc_mw = getCentralInverterDcMwdc();
    const central_skid_mva = getCentralSkidMva();
    const dc_ac_ratio = inv_ac_mw > 0 ? inv_dc_mw / inv_ac_mw : 1.2;
    const str_per_cb = intVal("str_per_cb_c", 1);
    const inv_per_mv = intVal("inv_per_mv_c");
    const mv_per_ring = intVal("mv_per_ring_c");
    const rings = intVal("rings_c");
    const combiner_design_limit_kwdc = num("combiner_limit_kwdc_c") || 500;

    if (physical.mod_wp <= 0 || physical.mod_l <= 0 || physical.mod_w <= 0 || x_mods <= 0) {
        return zeroStats(dc_ac_ratio, physical.mods_pallet, physical.mods_container);
    }

    const str_dc_kwp = (x_mods * physical.mod_wp) / 1000;
    const combiner_box_dc_kw = str_per_cb * str_dc_kwp;
    const req_strings = str_dc_kwp > 0 ? Math.ceil((inv_dc_mw * 1000) / str_dc_kwp) : 0;
    const combiner_boxes_per_inverter = Math.ceil(req_strings / str_per_cb);
    const total_blocks = inv_per_mv * mv_per_ring * rings;
    const total_combiner_boxes = combiner_boxes_per_inverter * total_blocks;
    const module_count = req_strings * x_mods * total_blocks;
    const ac_mw_direct = total_blocks * central_skid_mva * inv_per_mv;
    const production_substation_ac_mva = central_skid_mva * inv_per_mv;
    const ring_main_ac_mva = production_substation_ac_mva * mv_per_ring;

    let engineering_warning = "Check skid rating, transformer rating, cable ratings, protection, losses and grid compliance.";
    if (combiner_box_dc_kw > combiner_design_limit_kwdc) engineering_warning = "Combiner box DC capacity exceeds the selected design limit.";
    if (inv_ac_mw > central_skid_mva) engineering_warning = "Central inverter AC output exceeds skid transformer rating. Verify thermal rating and export limitation.";
    if (inv_ac_mw > 10) engineering_warning = "Large central inverter or power block selected. Verify transformer, MV switchgear, harmonics, thermal loading, protection and grid code compliance.";

    return buildStats({
        total_blocks, module_count, ac_mw_direct, dc_ac_ratio, physical,
        combiner_boxes_per_inverter, total_combiner_boxes,
        production_substation_ac_mva, ring_main_ac_mva,
        central_inverter_mwac: inv_ac_mw, central_inverter_mwdc: inv_dc_mw,
        combiner_box_dc_kw, combiner_design_limit_kwdc,
        engineering_warning
    });
}

function computeStats() {
    return state.activeTab === "string" ? computeStringStats() : computeCentralStats();
}

// ============================================================