In this section
- V10 Development — Authority Page render · solar-electrical-topology-analysis-engine-text-based / v10-development/authority/index.html lines 1–94
- Geometry Workbench render · solar-electrical-topology-analysis-engine-text-based / v10-development/geometry-workbench.html lines 1–85
- Solar Electrical Topology Analysis Engine Text Based — V10 Development Page render · solar-electrical-topology-analysis-engine-text-based / v10-development/index.html lines 1–21
- Electrical electrical · solar-electrical-topology-analysis-engine-text-based / v10-development/src/electrical.mjs lines 1–103
- Kernel render · solar-electrical-topology-analysis-engine-text-based / v10-development/src/kernel.mjs lines 1–133
- Quantity transform · solar-electrical-topology-analysis-engine-text-based / v10-development/src/quantity.mjs lines 1–95
- Topology transform · solar-electrical-topology-analysis-engine-text-based / v10-development/src/topology.mjs lines 1–152
V10 Development — Authority Page
A web page in Solar Electrical Topology Analysis Engine Text Based that selects mode (`selectMode`) and draws SVG graphics. Published at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/v10-development/authority/. It selects mode (`selectMode`).
rendersolar-electrical-topology-analysis-engine-text-based / v10-development/authority/index.html · lines 1–94 of 94 · Entry point
- What it does
- It draws its content. Defines selectMode. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage sub33kv_design (repository name word 'solar'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary.
- Inputs & outputs
- Out: web page; SVG drawing.
- Downstream impact
- Used directly by 1 file: Solar Electrical Topology Analysis Engine Text Based — V10 Development Page (solar-electrical-topology-analysis-engine-text-based, https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/v10-development/). Reached from 125 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 V002 (globalgrid2050, https://globalgrid2050.com/homepage_versions/homepage_v002.html). It is itself an entry point, published at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/v10-development/authority/.
- What it achieves
- Solar DC Topology Studio. It responds to click events.
- Why it matters
- Loaded by the V10 Development page at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/v10-development/.
- Application
- solar-electrical-topology-analysis-engine-text-based · v10-development/authority · page
- Uses
- Authority View (script src), Authority Evidence (script src)
- Used by
- linked from Solar Electrical Topology Analysis Engine Text Based — V10 Development Page (link)
- Produces
- selectMode
- Defines here
- selectMode
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- solar-electrical-topology-analysis-engine-text-based@d3b4c497144c2c9b3e8f0e82117e7e9abe4672b9 v10-development/authority/index.html:1-94 · blob e52fa5f3d851e9e92227416b99edb5856a225d79 · 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Solar DC Topology Studio</title>
<style>
:root{color-scheme:dark;--bg:#05090d;--panel:#0b151d;--line:#29485b;--text:#e9f4fa;--muted:#91a9b8;--cyan:#51d8ff;--amber:#ffb84d;--green:#55dda0;--red:#ff8068;--blue:#6bc3ff}
*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--text);font:14px/1.45 system-ui,sans-serif}header{padding:18px 20px;border-bottom:1px solid var(--line)}h1{margin:.2em 0}.sub{color:var(--muted);max-width:980px}.modes{display:flex;gap:8px;flex-wrap:wrap;margin-top:14px}.modes button{border:1px solid #3d6276;border-radius:7px;background:#0d1d27;color:var(--text);padding:9px … [line shortened here: 2,516 characters; full line on GitHub]
</style>
</head>
<body>
<header>
<div>GLOBALGRID2050 · SOLAR DC TOPOLOGY STUDIO</div>
<h1>Play freely. Verify through one engineering authority.</h1>
<p class="sub">The Playground preserves the existing browser experiment. Authority mode is a separate projection lane and displays only values, evidence states, coordinates, conductor vertices and hashes already contained in a Python-owned response bundle.</p>
<div class="modes" role="tablist" aria-label="Studio mode">
<button id="playground-tab" type="button" role="tab" data-mode="playground" aria-controls="playground-view" aria-selected="true">Playground</button>
<button id="authority-tab" type="button" role="tab" data-mode="authority" aria-controls="authority-view" aria-selected="false">Authority</button>
</div>
</header>
<main>
<section id="playground-view" class="view playground" role="tabpanel" data-authority-state="non-authoritative">
<div class="banner" role="status">INDICATIVE — NON-AUTHORITATIVE</div>
<iframe src="../topology-studio.html" title="Indicative topology playground" sandbox="allow-scripts allow-downloads"></iframe>
</section>
<section id="authority-view" class="view authority" role="tabpanel" data-authority-state="loading" hidden>
<div id="authority-banner" class="banner" role="status">PYTHON AUTHORITY — LOADING VERIFIED BUNDLE</div>
<div class="authority-grid">
<div class="authority-card"><span>Strategy</span><strong id="authority-strategy">—</strong></div>
<div class="authority-card"><span>Module rating</span><strong id="authority-module-power">—</strong></div>
<div class="authority-card"><span>Modules / string</span><strong id="authority-modules-per-string">—</strong></div>
<div class="authority-card"><span>Strings</span><strong id="authority-string-count">—</strong></div>
<div class="authority-card"><span>Total modules</span><strong id="authority-module-count">—</strong></div>
<div class="authority-card"><span>DC nameplate</span><strong id="authority-dc-power">—</strong></div>
<div class="authority-card"><span>Inverter apparent power</span><strong id="authority-inverter-power">—</strong></div>
<div class="authority-card"><span>DC / AC nameplate ratio</span><strong id="authority-dc-ac-ratio">—</strong></div>
<div class="authority-card"><span>Equipment evidence state</span><strong id="authority-evidence-state">—</strong></div>
<div class="authority-card"><span>Unresolved evidence fields</span><strong id="authority-missing-evidence">—</strong></div>
<div class="authority-card"><span>Rendered module centres</span><strong id="authority-rendered-modules">—</strong></div>
<div class="authority-card"><span>Rendered conductor polylines</span><strong id="authority-rendered-routes">—</strong></div>
<div class="authority-card"><span>Physical DC inputs</span><strong id="authority-physical-input-count">—</strong></div>
<div class="authority-card"><span>Allocated physical inputs</span><strong id="authority-allocated-input-count">—</strong></div>
<div class="authority-card"><span>Equipment MPPT count</span><strong id="authority-equipment-mppt-count">—</strong></div>
<div class="authority-card"><span>MPPT mapping evidence</span><strong id="authority-equipment-mppt-state">—</strong></div>
<div class="authority-card"><span>Internal DC topology</span><strong id="authority-internal-topology">—</strong></div>
<div class="authority-card"><span>Reverse-current blocking</span><strong id="authority-reverse-blocking">—</strong></div>
<div class="authority-card"><span>PCE backfeed current</span><strong id="authority-pce-backfeed">—</strong></div>
<div class="authority-card"><span>Fixture labels are equipment evidence</span><strong id="authority-fixture-label-evidence">—</strong></div>
<div class="authority-card hash"><span>Authority response hash</span><strong id="authority-response-hash">—</strong></div>
<div class="authority-card hash"><span>Inverter-block receipt hash</span><strong id="authority-block-hash">—</strong></div>
<div class="authority-card hash"><span>Build 025 child receipt hash</span><strong id="authority-build025-hash">—</strong></div>
<div class="authority-note">Every displayed scalar, module centre and conductor vertex is copied from the committed response bundle. This page does not derive route lengths, resistance, voltage drop, loss or evidence conclusions.</div>
<div class="authority-warning"><strong>Routing-fixture labels are not equipment evidence.</strong> Any MPPT-shaped text inside a fixture input identifier is preserved only as an existing routing label. Equipment MPPT mapping, internal connectivity, reverse-current blocking and PCE backfeed remain unresolved.</div>
<div class="authority-list">
<h2>Physical input allocation</h2>
<pre>NO. | ROUTING FIXTURE INPUT ID | STRING ID | EQUIPMENT MPPT
<span id="authority-input-lines">—</span></pre>
</div>
<div class="authority-list">
<h2>Unresolved equipment evidence</h2>
<pre id="authority-evidence-lines">—</pre>
</div>
<div class="authority-geometry">
<svg id="authority-geometry" viewBox="-6 0 42 56" role="img" aria-label="Python-owned module centres and conductor routes">
<g id="authority-route-layer"></g>
<g id="authority-module-layer"></g>
</svg>
</div>
</div>
</section>
</main>
<script>
(() => {
'use strict';
const tabs = [...document.querySelectorAll('[data-mode]')];
const views = {
playground: document.getElementById('playground-view'),
authority: document.getElementById('authority-view')
};
function selectMode(mode) {
for (const tab of tabs) tab.setAttribute('aria-selected', String(tab.dataset.mode === mode));
for (const [name, view] of Object.entries(views)) view.hidden = name !== mode;
}
for (const tab of tabs) tab.addEventListener('click', () => selectMode(tab.dataset.mode));
})();
</script>
<script type="module" src="./authority-view.js"></script>
<script type="module" src="./authority-evidence.js"></script>
</body>
</html>Geometry Workbench
A web page in Solar Electrical Topology Analysis Engine Text Based that draws geometry study and cables. Published at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/v10-development/geometry-workbench.html.
rendersolar-electrical-topology-analysis-engine-text-based / v10-development/geometry-workbench.html · lines 1–85 of 85 · Entry point
- What it does
- It draws geometry study and cables. Defines 8 functions or classes, including $, fmt, read, seq, moduleTerm. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage sub33kv_design (repository name word 'solar'): 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.
- Inputs & outputs
- In: form fields (user input). Out: JSON file v10-geometry-study.json; downloaded file v10-geometry-study.json; web page; SVG drawing.
- Downstream impact
- It is itself an entry point, published at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/v10-development/geometry-workbench.html.
- What it achieves
- It routes length (`routeLength`) and is built from the fmt step (`fmt`) and the read step (`read`). Geometry-derived 24-string PV topology workbench with V7 overview and V8 detailed connection modes. It responds to input events.
- Why it matters
- No other file in the estate was found to import it; it is an entry point.
- Application
- solar-electrical-topology-analysis-engine-text-based · v10-development · page
- Uses
- Progress Dashboard (link), Solar Electrical Topology Analysis Engine Text Based — V8 Leapfrog Page (link), V7 Development — Feed I Page (link), Solar Electrical Topology Analysis Engine Text Based — Index Page (link)
- Used by
- none found
- Produces
- $, fmt, read, seq, moduleTerm, routeLength, homeRoute, path
- Defines here
- $, fmt, read, seq, moduleTerm, routeLength, homeRoute, path
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- solar-electrical-topology-analysis-engine-text-based@d3b4c497144c2c9b3e8f0e82117e7e9abe4672b9 v10-development/geometry-workbench.html:1-85 · blob 1a5d71e0a0447ecfb769135b2175478156d6b8cf · 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>V10 Geometry Workbench · V7 Overview / V8 Detail</title>
<meta name="description" content="Geometry-derived 24-string PV topology workbench with V7 overview and V8 detailed connection modes.">
<style>
:root{color-scheme:dark;--bg:#05090d;--panel:#0b141c;--panel2:#0e1b25;--line:#29465a;--text:#e8f3fa;--muted:#91a9b9;--cyan:#50d7ff;--purple:#b586ff;--orange:#ffb84d;--good:#52dda0;--bad:#ff715f;--mono:ui-monospace,SFMono-Regular,Consolas,monospace}*{box-sizing:border-box}html,body{margin:0;background:var(--bg);color:var(--text);font:15px/1.45 system-ui,sans-serif}body{background:radial-gradient(ci … [line shortened here: 3,943 characters; full line on GitHub]
</style>
</head>
<body>
<header>
<div class="kicker">GLOBALGRID2050 · V10 GEOMETRY AUTHORITY</div>
<h1>V7 overview. V8 connection detail. One geometry model.</h1>
<p class="sub">Move the table geometry and every string position, home-run route and cable quantity is recomputed. The browser does not hand-draw cable: it renders deterministic coordinates and orthogonal route rules from the selected layout.</p>
<nav><a href="../progress-dashboard.html">Progress dashboard</a><a href="../v8-leapfrog/">Original V8</a><a href="../v7-development/feed-i/">Original V7</a><a href="../">V6 legacy</a></nav>
<div class="status"><span class="pill good" id="selftest">SELF-TESTING</span><span class="pill">24 STRINGS · 12 MPPT</span><span class="pill">NO USER-DRAWN ROUTES</span></div>
</header>
<div class="layout">
<aside class="panel">
<h2>Geometry inputs</h2>
<div class="section"><h3>View cartridge</h3><div class="modes"><button id="modeV7" class="active">V7 overview</button><button id="modeV8">V8 detail</button></div></div>
<div class="section"><h3>Topology</h3><div class="modes"><button id="topLeap" class="active">Leapfrog</button><button id="topSeq">Sequential</button></div></div>
<div class="section"><h3>Array table</h3>
<label>Strings <input id="strings" type="number" min="1" max="24" value="24"></label>
<label>Modules per string <input id="modules" type="number" min="2" max="40" value="30"></label>
<label>Rows per face <input id="rowsFace" type="number" min="1" max="12" value="4"></label>
<label>Strings per row <input id="stringsRow" type="number" min="1" max="6" value="3"></label>
<label>Module width along row (m) <input id="moduleWidth" type="number" min="0.1" step="0.001" value="1.303"></label>
<label>Module gap (m) <input id="moduleGap" type="number" min="0" step="0.001" value="0.020"></label>
<label>Gap between string blocks (m) <input id="stringGap" type="number" min="0" step="0.1" value="0.50"></label>
<label>Row pitch (m) <input id="rowPitch" type="number" min="1" step="0.1" value="6.5"></label>
<label>Gap between east/west faces (m) <input id="faceGap" type="number" min="0" step="0.5" value="8"></label>
</div>
<div class="section"><h3>Placement</h3>
<label>Array X from inverter (m) <input id="arrayX" type="number" step="0.5" value="20"></label>
<label>Array Y offset (m) <input id="arrayY" type="number" step="0.5" value="0"></label>
<label>Shared trench X (m) <input id="trenchX" type="number" step="0.5" value="12"></label>
<label>Inverter X (m) <input id="inverterX" type="number" step="0.5" value="0"></label>
<label>Inverter Y (m) <input id="inverterY" type="number" step="0.5" value="0"></label>
<label>Route slack (%) <input id="slack" type="number" min="0" step="0.5" value="3"></label>
<label>Termination allowance per conductor (m) <input id="termination" type="number" min="0" step="0.1" value="1.5"></label>
</div>
<div class="section"><div class="actions"><button id="reset">Reset</button><button id="export">Export geometry JSON</button></div></div>
</aside>
<main class="panel">
<div class="canvas-head"><div class="modes"><button id="zoomOut">−</button><button id="fit">FIT</button><button id="zoomIn">+</button><span class="pill" id="zoomReadout">100%</span></div><div class="legend"><span><i style="background:#50d7ff"></i>east</span><span><i style="background:#b586ff"></i>west</span><span><i style="background:#ff8068"></i>positive</span><span><i style="background:#6bc3ff"> … [line shortened here: 431 characters; full line on GitHub]
<div class="canvas-wrap" id="scroller"><svg id="drawing" role="img" aria-label="Geometry-derived photovoltaic string topology"></svg></div>
<div class="note" id="modeNote"></div>
</main>
<aside class="panel">
<h2>Geometry quantities</h2>
<div class="metrics">
<div class="metric"><span>Row span</span><strong id="rowSpan">—</strong><small>derived</small></div>
<div class="metric"><span>Table width</span><strong id="tableWidth">—</strong><small>derived</small></div>
<div class="metric"><span>Total + cable</span><strong id="totalPos">—</strong><small>external home-runs</small></div>
<div class="metric"><span>Total − cable</span><strong id="totalNeg">—</strong><small>external home-runs</small></div>
<div class="metric"><span>Total external</span><strong id="totalCable">—</strong><small>all 24 strings</small></div>
<div class="metric"><span>Selected string</span><strong id="selectedId">S01</strong><small id="selectedFace">east</small></div>
</div>
<div class="section"><h3>Selected string</h3><div id="selectedMetrics"></div></div>
<div class="section"><h3>All-string quantities</h3><div class="table-wrap"><table><thead><tr><th>String</th><th>Face</th><th>Row</th><th>Col</th><th>+ m</th><th>− m</th><th>Total m</th></tr></thead><tbody id="qty"></tbody></table></div></div>
<div class="section"><h3>Calculation trace</h3><pre id="trace" class="trace"></pre></div>
</aside>
</div>
<script>
(()=>{'use strict';
const $=id=>document.getElementById(id);const n=id=>Number($(id).value);let mode='v7',topology='leapfrog',selected=1,zoom=1,study=null;
const defaults={strings:24,modules:30,rowsFace:4,stringsRow:3,moduleWidth:1.303,moduleGap:.020,stringGap:.5,rowPitch:6.5,faceGap:8,arrayX:20,arrayY:0,trenchX:12,inverterX:0,inverterY:0,slack:3,termination:1.5};
const fmt=(v,d=2)=>Number(v).toLocaleString('en-GB',{minimumFractionDigits:d,maximumFractionDigits:d});
function read(){const o={};Object.keys(defaults).forEach(k=>o[k]=n(k));o.strings=Math.max(1,Math.min(24,Math.round(o.strings)));o.modules=Math.max(2,Math.round(o.modules));o.rowsFace=Math.max(1,Math.round(o.rowsFace));o.stringsRow=Math.max(1,Math.round(o.stringsRow));return o}
function seq(count){return Array.from({length:count},(_,i)=>i+1)}function leap(count){const a=[],b=[];for(let i=1;i<=count;i+=2)a.push(i);for(let i=count%2===0?count:count-1;i>=2;i-=2)b.push(i);return a.concat(b)}
function moduleTerm(x,w,pol){return pol==='+'?x+w*.70:x+w*.30}
function routeLength(points){let L=0;for(let i=1;i<points.length;i++)L+=Math.hypot(points[i].x-points[i-1].x,points[i].y-points[i-1].y);return L}
function homeRoute(start,pol,inputIndex,p){const trench={x:p.trenchX,y:start.y};const invY=p.inverterY+(inputIndex-(p.strings-1)/2)*.22+(pol==='+'?.07:-.07);const pts=[start,trench,{x:p.trenchX,y:invY},{x:p.inverterX,y:invY}];return{points:pts,length:(routeLength(pts)*(1+p.slack/100)+p.termination)}}
function compute(p){const pitch=p.moduleWidth+p.moduleGap,rowSpan=p.modules*p.moduleWidth+(p.modules-1)*p.moduleGap,blockPitch=rowSpan+p.stringGap;const perFace=Math.ceil(p.strings/2),faceHeight=(p.rowsFace-1)*p.rowPitch,tableWidth=p.stringsRow*rowSpan+(p.stringsRow-1)*p.stringGap;const strings=[];for(let i=0;i<p.strings;i++){const face=i<perFace?'east':'west';const local=face==='east'?i:i-perFace … [line shortened here: 1,357 characters; full line on GitHub]
function path(points){return points.map((p,i)=>`${i?'L':'M'} ${p.x} ${p.y}`).join(' ')}function cable(d,cls){return `<path class="halo" d="${d}"/><path class="${cls}" d="${d}"/>`}
function overviewSvg(s){const scale=8,margin=70,maxX=Math.max(...s.strings.map(x=>x.x+s.rowSpan),s.p.trenchX,s.p.inverterX)+10,maxY=Math.max(...s.strings.map(x=>x.y))+12,W=(maxX+15)*scale,H=(maxY+18)*scale;let h=`<g transform="translate(${margin},${margin}) scale(${scale})">`;h+=`<rect class="inv" x="${s.p.inverterX-1.3}" y="${s.p.inverterY-3.2}" width="2.6" height="6.4" rx=".3"/><text class="svg- … [line shortened here: 1,572 characters; full line on GitHub]
function detailSvg(s){const st=s.strings[selected-1]||s.strings[0],count=s.p.modules,scale=42,mw=s.p.moduleWidth*scale,mh=100,gap=Math.max(5,s.p.moduleGap*scale),x0=190,rowY=110,invX=28,rowWidth=count*mw+(count-1)*gap,W=Math.max(1320,x0+rowWidth+100),H=520;const mods=new Map();for(let i=1;i<=count;i++){const x=x0+(i-1)*(mw+gap),cx=x+mw/2;mods.set(i,{x,cx,neg:cx-11,pos:cx+11})}const order=st.order; … [line shortened here: 2,587 characters; full line on GitHub]
function render(){study=compute(read());$('drawing').innerHTML=mode==='v7'?overviewSvg(study):detailSvg(study);$('drawing').style.width=`${zoom*100}%`;$('rowSpan').textContent=`${fmt(study.rowSpan)} m`;$('tableWidth').textContent=`${fmt(study.tableWidth)} m`;$('totalPos').textContent=`${fmt(study.totalPos,1)} m`;$('totalNeg').textContent=`${fmt(study.totalNeg,1)} m`;$('totalCable').textContent=`${ … [line shortened here: 2,311 characters; full line on GitHub]
function activate(id,on){$(id).classList.toggle('active',on)}$('modeV7').onclick=()=>{mode='v7';activate('modeV7',1);activate('modeV8',0);render()};$('modeV8').onclick=()=>{mode='v8';activate('modeV7',0);activate('modeV8',1);render()};$('topLeap').onclick=()=>{topology='leapfrog';activate('topLeap',1);activate('topSeq',0);render()};$('topSeq').onclick=()=>{topology='sequential';activate('topLeap', … [line shortened here: 1,220 characters; full line on GitHub]
function tests(){const p={...defaults},a=compute(p),base=a.totalPos+a.totalNeg;p.arrayX+=10;const b=compute(p),moved=b.totalPos+b.totalNeg;const ok=a.strings.length===24&&a.strings[23].mppt===12&&leap(30)[29]===2&&a.strings[0].freePos.x<a.strings[0].x+3*a.pitch&&moved>base;$('selftest').textContent=ok?'SELF-TESTS GREEN':'SELF-TEST FAILED';$('selftest').className='pill '+(ok?'good':'');return ok}re … [line shortened here: 415 characters; full line on GitHub]
})();
</script>
</body></html>Solar Electrical Topology Analysis Engine Text Based — V10 Development Page
A web page. Published at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/v10-development/.
rendersolar-electrical-topology-analysis-engine-text-based / v10-development/index.html · lines 1–21 of 21 · Entry point
- What it does
- It draws its content. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage sub33kv_design (repository name word 'solar'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary.
- Inputs & outputs
- Out: web page.
- Downstream impact
- Used directly by 40 files: Inverter24 (solar-electrical-topology-analysis-engine-text-based, https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/v8-leapfrog/inverter24.html); GlobalGrid2050 Historical Builds (globalgrid2050, https://globalgrid2050.com/historical_builds.html); Homepage Versions — GlobalGrid2050 Page (globalgrid2050, https://globalgrid2050.com/homepage_versions/202608291526-globalgrid2050/); Homepage V002 (globalgrid2050, https://globalgrid2050.com/homepage_versions/homepage_v002.html); and 36 more. Reached from 85 other entry points, including 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); Homepage V038 (globalgrid2050, https://globalgrid2050.com/homepage_versions/homepage_v038.html). It is itself an entry point, published at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/v10-development/.
- What it achieves
- Solar DC Topology Studio — MVP Simulator.
- Why it matters
- Loaded by the Inverter24 page at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/v8-leapfrog/inverter24.html and 39 other pages.
- Application
- solar-electrical-topology-analysis-engine-text-based · v10-development · page
- Uses
- V10 Development — Authority Page (link)
- Used by
- linked from Inverter24 (link), named by URL in GlobalGrid2050 Historical Builds (estate URL), named by URL in Homepage Versions — GlobalGrid2050 Page (estate URL), named by URL in Homepage V002 (estate URL), named by URL in Homepage V003 (estate URL), named by URL in Homepage V004 (estate URL), named by URL in Homepage V005 (estate URL), named by URL in Homepage V006 (estate URL), and 32 more
- 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
- solar-electrical-topology-analysis-engine-text-based@d3b4c497144c2c9b3e8f0e82117e7e9abe4672b9 v10-development/index.html:1-21 · blob cf1c6de9add4c1a78237c32ef4c26b4cc1b5509e · 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta http-equiv="refresh" content="0; url=./authority/">
<title>Solar DC Topology Studio — MVP Simulator</title>
<link rel="canonical" href="./authority/">
<style>
body{margin:0;background:#05090d;color:#e8f3fa;font:16px/1.5 system-ui;display:grid;place-items:center;min-height:100vh;padding:24px;text-align:center}
a{color:#50d7ff}.card{max-width:650px;border:1px solid #29485b;border-radius:12px;background:#0b151d;padding:24px}.flag{color:#ffb84d;font:800 12px ui-monospace;letter-spacing:.1em}
</style>
</head>
<body>
<div class="card">
<div class="flag">MVP SIMULATOR · PLAYGROUND READY</div>
<p>Opening the <a href="./authority/">Solar DC Topology Studio</a>…</p>
<p>The Playground is interactive and indicative. Python Authority remains a separate read-only lane.</p>
</div>
</body>
</html>Electrical
A JavaScript module in Solar Electrical Topology Analysis Engine Text Based that works with require unit (`requireUnit`) and conductor resistance (`conductorResistance`) (units: Ω).
electricalsolar-electrical-topology-analysis-engine-text-based / v10-development/src/electrical.mjs · lines 1–103 of 103
- What it does
- It calculates its inputs. Defines 6 functions or classes, including requireUnit, conductorResistance, voltageDrop, resistivePowerLoss, coldCorrectedModuleVoc.
- Why it exists in the grid workflow
- Domain stage sub33kv_design (repository name word 'solar'): 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: Kernel (solar-electrical-topology-analysis-engine-text-based); Cross Language Test (solar-electrical-topology-analysis-engine-text-based). Reached from 1 other entry point, including Restore Points — 2026 07 29 Before 24 String V10 Page (solar-electrical-topology-analysis-engine-text-based, https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/restore-points/2026-07-29-before-24-string-v10/).
- What it achieves
- It is built from the require unit helper (`requireUnit`), the conductor resistance helper (`conductorResistance`) and the voltage drop helper (`voltageDrop`). Defines `requireUnit`, `conductorResistance`, `voltageDrop` and 3 more.
- Why it matters
- Imported by Kernel. Checked by Cross Language Test.
- Application
- solar-electrical-topology-analysis-engine-text-based · v10-development/src · JavaScript module
- Uses
- Quantity (import)
- Used by
- imported by Kernel (import), imported by Cross Language Test (import)
- Produces
- conductorResistance, voltageDrop, resistivePowerLoss, coldCorrectedModuleVoc, seriesStringVoltage
- Defines here
- requireUnit, conductorResistance, voltageDrop, resistivePowerLoss, coldCorrectedModuleVoc, seriesStringVoltage
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- solar-electrical-topology-analysis-engine-text-based@d3b4c497144c2c9b3e8f0e82117e7e9abe4672b9 v10-development/src/electrical.mjs:1-103 · blob 69d4e23331a4c82b05e0f60109d2dd5664223a0d · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: transform · effects: none found · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
import { deriveQuantity, intervalBounds } from "./quantity.mjs";
function requireUnit(q, unit, name) {
if (!q || q.unit !== unit) throw new TypeError(`${name} must use unit ${unit}`);
}
export function conductorResistance({ resistancePerMetre, length, circuitFactor = 1, id = "conductorResistance" }) {
requireUnit(resistancePerMetre, "ohmPerMetre", "resistancePerMetre");
requireUnit(length, "m", "length");
if (!Number.isFinite(circuitFactor) || circuitFactor <= 0) {
throw new TypeError("circuitFactor must be a finite positive number");
}
const value = resistancePerMetre.value * length.value * circuitFactor;
const [rLo, rHi] = intervalBounds(resistancePerMetre);
const [lLo, lHi] = intervalBounds(length);
return deriveQuantity({
id,
value,
unit: "ohm",
inputs: [resistancePerMetre, length],
equationId: "V10-R-001:R=Rprime*L*circuitFactor",
uncertainty: { kind: "interval", lo: rLo * lLo * circuitFactor, hi: rHi * lHi * circuitFactor },
});
}
export function voltageDrop({ current, resistance, id = "voltageDrop" }) {
requireUnit(current, "A", "current");
requireUnit(resistance, "ohm", "resistance");
const value = current.value * resistance.value;
const [iLo, iHi] = intervalBounds(current);
const [rLo, rHi] = intervalBounds(resistance);
return deriveQuantity({
id,
value,
unit: "V",
inputs: [current, resistance],
equationId: "V10-V-001:dV=I*R",
uncertainty: { kind: "interval", lo: iLo * rLo, hi: iHi * rHi },
});
}
export function resistivePowerLoss({ current, resistance, id = "powerLoss" }) {
requireUnit(current, "A", "current");
requireUnit(resistance, "ohm", "resistance");
const value = current.value ** 2 * resistance.value;
const [iLo, iHi] = intervalBounds(current);
const [rLo, rHi] = intervalBounds(resistance);
return deriveQuantity({
id,
value,
unit: "W",
inputs: [current, resistance],
equationId: "V10-P-001:Ploss=I^2*R",
uncertainty: { kind: "interval", lo: iLo ** 2 * rLo, hi: iHi ** 2 * rHi },
});
}
export function coldCorrectedModuleVoc({ vocStc, betaPercentPerKelvin, minimumCellTemperature, id = "moduleVocCold" }) {
requireUnit(vocStc, "V", "vocStc");
requireUnit(betaPercentPerKelvin, "1", "betaPercentPerKelvin");
requireUnit(minimumCellTemperature, "K", "minimumCellTemperature");
const referenceTemperatureKelvin = 298.15;
const factor = 1 + (betaPercentPerKelvin.value / 100) * (minimumCellTemperature.value - referenceTemperatureKelvin);
if (factor <= 0) throw new RangeError("temperature correction produced a non-positive voltage factor");
const value = vocStc.value * factor;
const [vocLo, vocHi] = intervalBounds(vocStc);
const [betaLo, betaHi] = intervalBounds(betaPercentPerKelvin);
const [tempLo, tempHi] = intervalBounds(minimumCellTemperature);
const candidates = [];
for (const v of [vocLo, vocHi]) {
for (const beta of [betaLo, betaHi]) {
for (const temp of [tempLo, tempHi]) {
candidates.push(v * (1 + (beta / 100) * (temp - referenceTemperatureKelvin)));
}
}
}
return deriveQuantity({
id,
value,
unit: "V",
inputs: [vocStc, betaPercentPerKelvin, minimumCellTemperature],
equationId: "V10-VOC-001:VocT=VocSTC*(1+betaPercent*(T-298.15)/100)",
uncertainty: { kind: "interval", lo: Math.min(...candidates), hi: Math.max(...candidates) },
evidenceStatus: "candidate-needs-standards-verification",
});
}
export function seriesStringVoltage({ moduleVoltage, moduleCount, id = "stringVoltage" }) {
requireUnit(moduleVoltage, "V", "moduleVoltage");
if (!Number.isInteger(moduleCount) || moduleCount < 1) throw new TypeError("moduleCount must be a positive integer");
const [lo, hi] = intervalBounds(moduleVoltage);
return deriveQuantity({
id,
value: moduleVoltage.value * moduleCount,
unit: "V",
inputs: [moduleVoltage],
equationId: "V10-V-002:Vstring=N*Vmodule",
uncertainty: { kind: "interval", lo: lo * moduleCount, hi: hi * moduleCount },
});
}Kernel
A JavaScript module in Solar Electrical Topology Analysis Engine Text Based that works with require object (`requireObject`) (units: Ω). It is built from the require object helper (`requireObject`).
rendersolar-electrical-topology-analysis-engine-text-based / v10-development/src/kernel.mjs · lines 1–133 of 133 · Entry point · pattern requireObject (shared by 3 files)
- What it does
- Defines requireObject, runKernel. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage sub33kv_design (repository name word 'solar'): 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: Restore Points — 2026 07 29 Before 24 String V10 Page (solar-electrical-topology-analysis-engine-text-based, https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/restore-points/2026-07-29-before-24-string-v10/); Kernel Test (solar-electrical-topology-analysis-engine-text-based).
- What it achieves
- Defines `requireObject` and `runKernel`.
- Why it matters
- Loaded by the 2026 07 29 Before 24 String V10 page at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/restore-points/2026-07-29-before-24-string-v10/. Checked by Kernel Test.
- Application
- solar-electrical-topology-analysis-engine-text-based · v10-development/src · JavaScript module
- Uses
- Topology (import), Quantity (import), Electrical (import)
- Used by
- imported by Restore Points — 2026 07 29 Before 24 String V10 Page (import), imported by Kernel Test (import)
- Produces
- KERNEL_SCHEMA, runKernel
- Defines here
- requireObject, runKernel
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- solar-electrical-topology-analysis-engine-text-based@d3b4c497144c2c9b3e8f0e82117e7e9abe4672b9 v10-development/src/kernel.mjs:1-133 · blob 1d7549d9e2c26f9dc41b6bd4911c0f02a197f29c · 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
import { computeTopologyGeometry } from "./topology.mjs";
import { quantity } from "./quantity.mjs";
import {
coldCorrectedModuleVoc,
conductorResistance,
resistivePowerLoss,
seriesStringVoltage,
voltageDrop,
} from "./electrical.mjs";
export const KERNEL_SCHEMA = "globalgrid2050.solar-dc-computation.v10.kernel.1";
function requireObject(value, name) {
if (!value || typeof value !== "object" || Array.isArray(value)) {
throw new TypeError(`${name} must be an object`);
}
}
export function runKernel(document) {
requireObject(document, "document");
requireObject(document.layout, "document.layout");
requireObject(document.electrical, "document.electrical");
const geometry = computeTopologyGeometry(document.layout);
const q = document.electrical;
const conductorLength = quantity({
id: "geometry.pathLength",
value: geometry.pathLengthMetres,
unit: "m",
provenance: "geometryDerived",
uncertainty: q.lengthUncertaintyMetres
? {
kind: "interval",
lo: Math.max(0, geometry.pathLengthMetres - q.lengthUncertaintyMetres),
hi: geometry.pathLengthMetres + q.lengthUncertaintyMetres,
}
: { kind: "none" },
source: { equationId: "V10-GEO-001:sum(segment.length)", inputIds: [] },
evidenceStatus: "candidate",
});
const resistancePerMetre = quantity({
id: "input.resistancePerMetre",
value: q.resistanceOhmPerMetre,
unit: "ohmPerMetre",
provenance: q.resistanceProvenance ?? "datasheet",
uncertainty: q.resistanceIntervalOhmPerMetre
? { kind: "interval", ...q.resistanceIntervalOhmPerMetre }
: { kind: "none" },
source: q.resistanceSource ?? null,
evidenceStatus: q.resistanceEvidenceStatus ?? "unverified",
});
const current = quantity({
id: "input.current",
value: q.currentAmps,
unit: "A",
provenance: q.currentProvenance ?? "datasheet",
uncertainty: q.currentIntervalAmps
? { kind: "interval", ...q.currentIntervalAmps }
: { kind: "none" },
source: q.currentSource ?? null,
evidenceStatus: q.currentEvidenceStatus ?? "unverified",
});
const resistance = conductorResistance({
resistancePerMetre,
length: conductorLength,
circuitFactor: q.circuitFactor ?? 1,
});
const drop = voltageDrop({ current, resistance });
const loss = resistivePowerLoss({ current, resistance });
let voltageLimits = null;
if (q.vocStcVolts != null && q.betaVocPercentPerKelvin != null && q.minimumCellTemperatureKelvin != null) {
const vocStc = quantity({
id: "input.vocStc",
value: q.vocStcVolts,
unit: "V",
provenance: q.vocProvenance ?? "datasheet",
uncertainty: q.vocIntervalVolts ? { kind: "interval", ...q.vocIntervalVolts } : { kind: "none" },
source: q.vocSource ?? null,
evidenceStatus: q.vocEvidenceStatus ?? "unverified",
});
const beta = quantity({
id: "input.betaVoc",
value: q.betaVocPercentPerKelvin,
unit: "1",
provenance: q.betaVocProvenance ?? "datasheet",
uncertainty: q.betaVocIntervalPercentPerKelvin
? { kind: "interval", ...q.betaVocIntervalPercentPerKelvin }
: { kind: "none" },
source: q.betaVocSource ?? null,
evidenceStatus: q.betaVocEvidenceStatus ?? "unverified",
});
const minimumTemperature = quantity({
id: "input.minimumCellTemperature",
value: q.minimumCellTemperatureKelvin,
unit: "K",
provenance: q.temperatureProvenance ?? "assumed",
uncertainty: q.minimumCellTemperatureIntervalKelvin
? { kind: "interval", ...q.minimumCellTemperatureIntervalKelvin }
: { kind: "none" },
source: q.temperatureSource ?? null,
evidenceStatus: q.temperatureEvidenceStatus ?? "unverified",
});
const moduleVocCold = coldCorrectedModuleVoc({
vocStc,
betaPercentPerKelvin: beta,
minimumCellTemperature: minimumTemperature,
});
voltageLimits = {
moduleVocCold,
stringVocCold: seriesStringVoltage({ moduleVoltage: moduleVocCold, moduleCount: geometry.moduleCount }),
};
}
return {
schemaVersion: KERNEL_SCHEMA,
documentId: document.documentId ?? null,
geometry,
results: {
conductorLength,
resistance,
voltageDrop: drop,
resistivePowerLoss: loss,
voltageLimits,
},
warnings: [
"Candidate kernel: outputs are not compliance conclusions.",
"Path length currently follows module-centre geometry and does not yet include terminal offsets, lead slack or routed field cable.",
],
};
}Quantity
A JavaScript module in Solar Electrical Topology Analysis Engine Text Based that normalises interval (`normaliseInterval`) (units: Ω).
transformsolar-electrical-topology-analysis-engine-text-based / v10-development/src/quantity.mjs · lines 1–95 of 95 · pattern quantity (shared by 4 files)
- What it does
- It calculates its inputs. Defines 6 functions or classes, including assertFinite, normaliseInterval, quantity, weakestProvenance, intervalBounds.
- Why it exists in the grid workflow
- Domain stage sub33kv_design (repository name word 'solar'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary.
- Downstream impact
- Used directly by 4 files: Electrical (solar-electrical-topology-analysis-engine-text-based); Kernel (solar-electrical-topology-analysis-engine-text-based); Cross Language Test (solar-electrical-topology-analysis-engine-text-based); Kernel Test (solar-electrical-topology-analysis-engine-text-based). Reached from 1 other entry point, including Restore Points — 2026 07 29 Before 24 String V10 Page (solar-electrical-topology-analysis-engine-text-based, https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/restore-points/2026-07-29-before-24-string-v10/).
- What it achieves
- It normalises interval (`normaliseInterval`) and is built from the assert finite helper (`assertFinite`) and the weakest provenance helper (`weakestProvenance`). Defines `assertFinite`, `normaliseInterval`, `quantity` and 3 more.
- Why it matters
- Imported by Electrical and Kernel. Checked by 2 tests, including Cross Language Test.
- Application
- solar-electrical-topology-analysis-engine-text-based · v10-development/src · JavaScript module
- Uses
- none found
- Used by
- imported by Electrical (import), imported by Kernel (import), imported by Cross Language Test (import), imported by Kernel Test (import)
- Produces
- PROVENANCE_RANK, quantity, weakestProvenance, intervalBounds, deriveQuantity
- Defines here
- assertFinite, normaliseInterval, quantity, weakestProvenance, intervalBounds, deriveQuantity
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- solar-electrical-topology-analysis-engine-text-based@d3b4c497144c2c9b3e8f0e82117e7e9abe4672b9 v10-development/src/quantity.mjs:1-95 · blob 218069827896ffcce2f9c95cfa1016c240e45760 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: transform · effects: none found · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
export const PROVENANCE_RANK = Object.freeze({
measured: 4,
datasheet: 3,
standardsDerived: 3,
geometryDerived: 3,
inherited: 2,
assumed: 1,
researchHypothesis: 0,
});
const DIMENSIONS = Object.freeze({
"1": {},
m: { length: 1 },
m2: { length: 2 },
A: { current: 1 },
V: { mass: 1, length: 2, time: -3, current: -1 },
ohm: { mass: 1, length: 2, time: -3, current: -2 },
W: { mass: 1, length: 2, time: -3 },
K: { temperature: 1 },
ohmPerMetre: { mass: 1, length: 1, time: -3, current: -2 },
});
function assertFinite(value, name) {
if (!Number.isFinite(value)) throw new TypeError(`${name} must be finite`);
}
function normaliseInterval(value, uncertainty) {
if (!uncertainty) return { kind: "none" };
if (uncertainty.kind === "none") return uncertainty;
if (uncertainty.kind === "interval") {
assertFinite(uncertainty.lo, "uncertainty.lo");
assertFinite(uncertainty.hi, "uncertainty.hi");
if (uncertainty.lo > uncertainty.hi) throw new RangeError("interval lo must not exceed hi");
if (value < uncertainty.lo || value > uncertainty.hi) {
throw new RangeError("quantity value must lie inside its uncertainty interval");
}
return { kind: "interval", lo: uncertainty.lo, hi: uncertainty.hi };
}
throw new TypeError(`unsupported uncertainty kind: ${uncertainty.kind}`);
}
export function quantity({
id,
value,
unit,
provenance,
uncertainty = { kind: "none" },
source = null,
evidenceStatus = "unverified",
}) {
if (typeof id !== "string" || id.length === 0) throw new TypeError("quantity id is required");
assertFinite(value, "value");
if (!Object.hasOwn(DIMENSIONS, unit)) throw new TypeError(`unsupported unit: ${unit}`);
if (!Object.hasOwn(PROVENANCE_RANK, provenance)) {
throw new TypeError(`unsupported provenance: ${provenance}`);
}
return Object.freeze({
id,
value,
unit,
dimension: DIMENSIONS[unit],
provenance,
uncertainty: normaliseInterval(value, uncertainty),
source,
evidenceStatus,
});
}
export function weakestProvenance(inputs) {
if (!Array.isArray(inputs) || inputs.length === 0) throw new TypeError("inputs are required");
return inputs.reduce((weakest, item) =>
PROVENANCE_RANK[item.provenance] < PROVENANCE_RANK[weakest] ? item.provenance : weakest,
inputs[0].provenance);
}
export function intervalBounds(q) {
return q.uncertainty.kind === "interval"
? [q.uncertainty.lo, q.uncertainty.hi]
: [q.value, q.value];
}
export function deriveQuantity({ id, value, unit, inputs, equationId, uncertainty, evidenceStatus = "candidate" }) {
return quantity({
id,
value,
unit,
provenance: weakestProvenance(inputs),
uncertainty,
source: {
equationId,
inputIds: inputs.map((input) => input.id),
},
evidenceStatus,
});
}Topology
A JavaScript module in Solar Electrical Topology Analysis Engine Text Based that validates custom order (`validateCustomOrder`), derives ordered segments (`deriveOrderedSegments`) and calculates planar distances.
transformsolar-electrical-topology-analysis-engine-text-based / v10-development/src/topology.mjs · lines 1–152 of 152
- What it does
- It calculates its inputs. Defines 9 functions or classes, including assertPositiveInteger, assertFiniteNonNegative, sequentialOrder, mirroredSequentialOrder, canonicalLeapfrogOrder.
- Why it exists in the grid workflow
- Domain stage sub33kv_design (path word 'topology'): 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: Kernel (solar-electrical-topology-analysis-engine-text-based); Topology Test (solar-electrical-topology-analysis-engine-text-based). Reached from 1 other entry point, including Restore Points — 2026 07 29 Before 24 String V10 Page (solar-electrical-topology-analysis-engine-text-based, https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/restore-points/2026-07-29-before-24-string-v10/).
- What it achieves
- It validates custom order (`validateCustomOrder`), derives ordered segments (`deriveOrderedSegments`) and computes topology geometry (`computeTopologyGeometry`). Defines `assertPositiveInteger`, `assertFiniteNonNegative`, `sequentialOrder` and 6 more.
- Why it matters
- Imported by Kernel. Checked by Topology Test.
- Application
- solar-electrical-topology-analysis-engine-text-based · v10-development/src · JavaScript module
- Uses
- none found
- Used by
- imported by Kernel (import), imported by Topology Test (import)
- Produces
- TOPOLOGY_SCHEMA, sequentialOrder, mirroredSequentialOrder, canonicalLeapfrogOrder, validateCustomOrder, linearModuleCoordinates, deriveOrderedSegments, computeTopologyGeometry
- Defines here
- assertPositiveInteger, assertFiniteNonNegative, sequentialOrder, mirroredSequentialOrder, canonicalLeapfrogOrder, validateCustomOrder, linearModuleCoordinates, deriveOrderedSegments, computeTopologyGeometry
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- solar-electrical-topology-analysis-engine-text-based@d3b4c497144c2c9b3e8f0e82117e7e9abe4672b9 v10-development/src/topology.mjs:1-152 · blob 4298f43b878699254e4a6f8a881677911b2ae7ea · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: transform · effects: none found · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
export const TOPOLOGY_SCHEMA = "globalgrid2050.solar-dc-computation.v10.topology.1";
function assertPositiveInteger(value, name) {
if (!Number.isInteger(value) || value < 1) {
throw new TypeError(`${name} must be a positive integer`);
}
}
function assertFiniteNonNegative(value, name) {
if (!Number.isFinite(value) || value < 0) {
throw new TypeError(`${name} must be a finite non-negative number`);
}
}
export function sequentialOrder(moduleCount) {
assertPositiveInteger(moduleCount, "moduleCount");
return Array.from({ length: moduleCount }, (_, index) => index + 1);
}
export function mirroredSequentialOrder(moduleCount) {
return sequentialOrder(moduleCount).reverse();
}
export function canonicalLeapfrogOrder(moduleCount) {
assertPositiveInteger(moduleCount, "moduleCount");
const odd = [];
const even = [];
for (let moduleNumber = 1; moduleNumber <= moduleCount; moduleNumber += 1) {
(moduleNumber % 2 === 1 ? odd : even).push(moduleNumber);
}
return odd.concat(even.reverse());
}
export function validateCustomOrder(order, moduleCount) {
assertPositiveInteger(moduleCount, "moduleCount");
if (!Array.isArray(order) || order.length !== moduleCount) {
throw new TypeError("custom order must contain exactly moduleCount entries");
}
const expected = new Set(sequentialOrder(moduleCount));
const actual = new Set(order);
if (actual.size !== moduleCount) {
throw new TypeError("custom order contains duplicate module numbers");
}
for (const moduleNumber of actual) {
if (!expected.has(moduleNumber)) {
throw new TypeError("custom order must be an exact permutation of 1..moduleCount");
}
}
return [...order];
}
export function linearModuleCoordinates(moduleCount, pitchMetres, originMetres = 0) {
assertPositiveInteger(moduleCount, "moduleCount");
assertFiniteNonNegative(pitchMetres, "pitchMetres");
if (!Number.isFinite(originMetres)) {
throw new TypeError("originMetres must be finite");
}
return Array.from({ length: moduleCount }, (_, index) => ({
moduleNumber: index + 1,
xMetres: originMetres + index * pitchMetres,
yMetres: 0,
}));
}
export function deriveOrderedSegments(order, coordinates) {
if (!Array.isArray(order) || order.length < 1) {
throw new TypeError("order must contain at least one module");
}
if (!Array.isArray(coordinates) || coordinates.length < 1) {
throw new TypeError("coordinates must contain at least one module");
}
const coordinateByModule = new Map(
coordinates.map((coordinate) => [coordinate.moduleNumber, coordinate]),
);
return order.slice(0, -1).map((fromModule, index) => {
const toModule = order[index + 1];
const from = coordinateByModule.get(fromModule);
const to = coordinateByModule.get(toModule);
if (!from || !to) {
throw new TypeError("order references a module without coordinates");
}
const dx = to.xMetres - from.xMetres;
const dy = to.yMetres - from.yMetres;
return {
segmentIndex: index + 1,
fromModule,
toModule,
dxMetres: dx,
dyMetres: dy,
lengthMetres: Math.hypot(dx, dy),
};
});
}
export function computeTopologyGeometry({
moduleCount,
pitchMetres,
topology,
customOrder,
originMetres = 0,
}) {
const coordinates = linearModuleCoordinates(moduleCount, pitchMetres, originMetres);
let order;
switch (topology) {
case "sequential":
order = sequentialOrder(moduleCount);
break;
case "mirrored-sequential":
order = mirroredSequentialOrder(moduleCount);
break;
case "leapfrog":
order = canonicalLeapfrogOrder(moduleCount);
break;
case "custom":
order = validateCustomOrder(customOrder, moduleCount);
break;
default:
throw new TypeError(`unsupported topology: ${topology}`);
}
const segments = deriveOrderedSegments(order, coordinates);
const pathLengthMetres = segments.reduce((sum, segment) => sum + segment.lengthMetres, 0);
const firstTerminal = coordinates.find((item) => item.moduleNumber === order[0]);
const lastTerminal = coordinates.find((item) => item.moduleNumber === order.at(-1));
return {
schemaVersion: TOPOLOGY_SCHEMA,
moduleCount,
pitchMetres,
topology,
order,
coordinates,
segments,
pathLengthMetres,
terminalSeparationMetres: Math.hypot(
lastTerminal.xMetres - firstTerminal.xMetres,
lastTerminal.yMetres - firstTerminal.yMetres,
),
firstTerminalModule: order[0],
lastTerminalModule: order.at(-1),
};
}