In this section
- Solar Battery Energy Storage System (BESS) Topology V6 — Cable Geometry Visualiser Page render · globalgrid2050 / solar-bess-topology-v6/cable-geometry-visualiser/index.html lines 1–279
- Cable Route electrical · globalgrid2050 / solar-design-studio/202609270005-site-world-v3/world/cable-route.mjs lines 1–207
- Cable Rating electrical · globalgrid2050 / solar-design-studio/202609270220-site-world-v3/world/cable-rating.mjs lines 1–87
Solar Battery Energy Storage System (BESS) Topology V6 — Cable Geometry Visualiser Page
A web page in GlobalGrid2050 covering cables, 132kV, 33kV and solar, using BS EN 50618 and BS 7671, and uses data from UK Power Networks open data. Published at https://globalgrid2050.com/solar-bess-topology-v6/cable-geometry-visualiser/.
Set aside from the main view: 95% of its lines are the same as releases/202609052001/solar-bess-topology-v7/cable-geometry-visualiser/index.html (cable-trench-or-drill), which stays. (near-copy-of, proposed by families.py). 95% of lines shared with Solar Battery Energy Storage System (BESS) Topology V7 — Cable Geometry Visualiser Page; read that one first. All set-aside files, with reasons. Nothing was deleted.
Evidence
- line-jaccard 0.9536 to cable-trench-or-drill@bf00f9503ff7a662933775a022557c4ca9d9880a releases/202609052001/solar-bess-topology-v7/cable-geometry-visualiser/index.html:1-280 21fc7a76fb8d36c17b1d632f43e5cfcb4fb84d26
- sha256 f1f018f660d154ceedf77eff6d4e57becaa8cee1d8e2e8dc82389ffc661fdfea
- target sha256 59d1c5ce38463c7b5b08ab14a86b23a50941c74cb9c9ed2eb3fb97770741573c
- group of 2 (identity.json near-copy edges >= 0.9)
- canonical rule: reachable, newest stamp, core repo, most lines
renderglobalgrid2050 / solar-bess-topology-v6/cable-geometry-visualiser/index.html · lines 1–279 of 279 · Entry point
- What it does
- It draws cables, 132kV, 33kV and solar. 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. Domain terms in the code: cables, 132kV, 33kV, solar, 110kV, 66kV.
- Inputs & outputs
- In: form fields (user input). Out: web page. Voltage levels named: 132kV, 110kV, 66kV, 33kV, 20kV, 15kV, 10kV, 6kV.
- Downstream impact
- Used directly by 2 files: GlobalGrid2050 — Solar Battery Energy Storage System (BESS) Topology V6 Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v6/); Solar Battery Energy Storage System (BESS) Topology V6 — Module Layout Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v6/module-layout/). Reached from 1 other entry point, including 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/). It is itself an entry point, published at https://globalgrid2050.com/solar-bess-topology-v6/cable-geometry-visualiser/.
- What it achieves
- Its code works with 1 kV, 132 kV and 33 kV.
- Why it matters
- Loaded by the Solar Battery Energy Storage System (BESS) Topology V6 page at https://globalgrid2050.com/solar-bess-topology-v6/ and 1 other page.
- Application
- globalgrid2050 · solar-bess-topology-v6/cable-geometry-visualiser · page
- Uses
- Solar Battery Energy Storage System (BESS) Topology V7 — Cable Geometry Visualiser Style Sheet (stylesheet), Solar Battery Energy Storage System (BESS) Topology V6 — Module Layout Page (link), Solar Battery Energy Storage System (BESS) Topology V6 — DC AC LV Topology Review Page (link), Solar Battery Energy Storage System (BESS) Topology V7 — Cable Geometry Visualiser (script src), Calculations (script src), Rendering (script src), Export (script src), UI (script src)
- Used by
- linked from GlobalGrid2050 — Solar Battery Energy Storage System (BESS) Topology V6 Page (link), linked from Solar Battery Energy Storage System (BESS) Topology V6 — Module Layout Page (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-v6/cable-geometry-visualiser/index.html:1-279 · blob 31df600ce325615dd59b20b46b47b18a3035dd74 · 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" />
<title>Cable Geometry Visualiser V6 | GlobalGrid2050</title>
<link rel="stylesheet" href="./style.css" />
</head>
<body>
<div class="dashboard">
<div class="panel panel-left">
<h2>Cable Geometry Visualiser V6</h2>
<div class="guidance-box"><strong>GlobalGrid2050 V6 migration</strong><br>This page is migrated from the original cable geometry visualiser into the V5 toolset. It remains a geometry capture and visual review tool only. It does not perform electrical rating, thermal rating, cable sizing, protection grading or construction design.</div>
<div class="button-row">
<button id="cg_print_report" class="btn print-btn" type="button" onclick="window.print()">Print</button><a class="btn" href="../module-layout/index.html" style="text-align:center;text-decoration:none;">Module Layout V6</a><a class="btn btn-alt" href="../dc-ac-lv-topology-review/index.html" style="text-align:center;text-decoration:none;">DC AC LV Topology Review</a></div>
<h3 class="section-title">Geometry Inputs</h3>
<div class="warning-box">
This tool produces indicative geometry records only and must not be used for trench design, duct sizing, burial depth specification, electrical design or any construction document without independent verification by a competent engineer with responsibility for the project.<br>
No electrical calculation is performed.<br>
No thermal rating is performed.<br>
No compliance verdict is produced.<br>
No burial depth design advice is produced.<br>
The user must verify safety, installation depth, protection, rating and utility compliance with a competent person in accordance with local law, site conditions and the relevant power utility or infrastructure owner requirements.
</div>
<div id="status_box" class="status-box ok" aria-live="polite">Geometry only. Ready for capture.</div>
<h3>Route Identity</h3>
<div class="input-group">
<label for="route_name">Route ID</label>
<input type="text" id="route_name" value="M_W3_BESS_to_PCS" />
</div>
<div class="input-group">
<label for="section_length">Worst Case Section Length m</label>
<input type="text" inputmode="decimal" enterkeyhint="done" autocomplete="off" autocorrect="off" spellcheck="false" data-numeric="true" id="section_length" value="30" />
</div>
<h3 class="section-title">Installation Basis</h3>
<div class="input-group">
<label for="installation_condition">Installation Condition</label>
<select id="installation_condition">
<option value="buried_duct">Buried Duct</option>
<option value="direct_buried">Direct Buried</option>
<option value="open_trough">Open Trough</option>
<option value="free_air">Free Air on Cleats</option>
<option value="metallic_enclosure">Metallic Enclosure</option>
</select>
</div>
<div class="input-group">
<label for="service_type">Service Type</label>
<select id="service_type">
<option value="lv" selected>LV AC</option>
<option value="mv">33kV AC</option>
<option value="ehv">132kV AC</option>
<option value="dc">DC</option>
</select>
</div>
<div class="input-group">
<label for="grouping_basis">Grouping Basis</label>
<select id="grouping_basis">
<option value="same_circuit">Same Circuit</option>
<option value="same_service">Same Service</option>
<option value="mixed_service">Mixed Service</option>
</select>
</div>
<div class="input-group">
<label for="burial_depth">Burial Depth mm</label>
<input type="text" inputmode="decimal" enterkeyhint="done" autocomplete="off" autocorrect="off" spellcheck="false" data-numeric="true" id="burial_depth" value="900" />
</div>
<div class="inline-note" id="burial_note">Indicative cover or depth input only. Verify with competent person and utility standard.</div>
<h3 class="section-title">Cable OD Lookup</h3>
<div class="input-group">
<label for="lookup_cores">Cores</label>
<select id="lookup_cores">
<option value="single">Single Core</option>
<option value="three">Three Core</option>
</select>
</div>
<div class="input-group">
<label for="lookup_voltage">Voltage Class</label>
<select id="lookup_voltage">
<option value="">— manual OD entry —</option>
<optgroup label="LV Power — 0.6/1kV XLPE, Cu conductor">
<option value="lv_cu_sc">0.6/1kV Cu XLPE single core (AWA)</option>
<option value="lv_cu_2c">0.6/1kV Cu XLPE 2-core SWA</option>
<option value="lv_cu_3c">0.6/1kV Cu XLPE 3-core SWA</option>
<option value="lv_cu_4c">0.6/1kV Cu XLPE 4-core SWA</option>
<option value="lv_cu_5c">0.6/1kV Cu XLPE 5-core SWA</option>
</optgroup>
<optgroup label="LV Power — 0.6/1kV XLPE, Al conductor">
<option value="lv_al_sc">0.6/1kV Al XLPE single core (AWA)</option>
<option value="lv_al_3c">0.6/1kV Al XLPE 3-core SWA</option>
<option value="lv_al_4c">0.6/1kV Al XLPE 4-core SWA</option>
<option value="lv_al_5c">0.6/1kV Al XLPE 5-core SWA</option>
</optgroup>
<optgroup label="LV — Multicore, fixed installation">
<option value="lv3">LV 0.6/1kV 3-core</option>
</optgroup>
<optgroup label="Solar PV — DC string (flexible Cu, 1500V DC only)">
<option value="pv_string">1500V DC string — BS EN 50618 Class II</option>
</optgroup>
<optgroup label="Solar PV — Flexible screened (Cu screened, fixed/occasional)">
<option value="flex_hv_ac">1000/1000V AC — IT system (Uo=1000V ≥ inverter Vac)</option>
<option value="flex_hv_dc">1500V DC — flexible screened</option>
</optgroup>
<optgroup label="Solar PV — Rigid Al, Al tube armour (non-magnetic, fixed only)">
<option value="al_ata_ac">1000/1000V AC — Al tube armour, IT system</option>
<option value="al_ata_dc">1500/1500V DC — Al tube armour</option>
</optgroup>
<optgroup label="MV XLPE — fixed installation">
<option value="6">6 kV (3.6/6 kV)</option>
<option value="10">10 kV (5.8/10 kV)</option>
<option value="15">15 kV (8.7/15 kV)</option>
<option value="20">20 kV (12/20 kV)</option>
<option value="33">33 kV (19/33 kV) — Al</option>
<option value="33cu">33 kV (19/33 kV) — Cu 3-core</option>
</optgroup>
<optgroup label="HV XLPE — fixed installation ★ confirmed datasheets">
<option value="66">66 kV (38/66 kV) ★</option>
<option value="110">110 kV (64/110 kV) ★</option>
<option value="132">132 kV (76/132 kV) ★</option>
</optgroup>
</select>
</div>
<div class="input-group">
<label for="lookup_csa">Conductor CSA mm²</label>
<select id="lookup_csa">
<option value="">— select voltage first —</option>
</select>
</div>
<div class="inline-note" id="lookup_note">Select voltage and CSA to auto-populate OD and bend factor. All values are for <strong>fixed installation</strong> only. Flexible applications, very tight bend radii, cleats and terminations must be verified with the cable manufacturer. ★ = anchored on confirmed datasheets. Others from catalogue model. Indicative only.</div>
<h3 class="section-title">Formation</h3>
<div class="input-group">
<label for="formation_type">Formation Type</label>
<select id="formation_type"></select>
</div>
<div class="input-group">
<label for="circuit_qty">Number of Circuit Groups</label>
<input type="text" inputmode="decimal" enterkeyhint="done" autocomplete="off" autocorrect="off" spellcheck="false" data-numeric="true" id="circuit_qty" value="4" />
</div>
<div class="input-group">
<label for="max_per_row">Max Groups per Row</label>
<input type="text" inputmode="decimal" enterkeyhint="done" autocomplete="off" autocorrect="off" spellcheck="false" data-numeric="true" id="max_per_row" value="2" />
</div>
<div class="input-group">
<label for="cable_od">Cable Outer Diameter mm</label>
<input type="text" inputmode="decimal" enterkeyhint="done" autocomplete="off" autocorrect="off" spellcheck="false" data-numeric="true" id="cable_od" value="45" />
</div>
<div class="inline-note" id="od_source_note">OD entered manually.</div>
<div class="input-group">
<label for="spacing_basis">Spacing Basis</label>
<select id="spacing_basis">
<option value="clear_gap">Clear Gap</option>
<option value="touching">Touching</option>
<option value="centre_to_centre">Centre to Centre</option>
</select>
</div>
<div class="input-group">
<label for="spacing_h">Horizontal Spacing mm</label>
<input type="text" inputmode="decimal" enterkeyhint="done" autocomplete="off" autocorrect="off" spellcheck="false" data-numeric="true" id="spacing_h" value="150" />
</div>
<div class="input-group">
<label for="spacing_v">Vertical Spacing mm</label>
<input type="text" inputmode="decimal" enterkeyhint="done" autocomplete="off" autocorrect="off" spellcheck="false" data-numeric="true" id="spacing_v" value="150" />
</div>
<div class="inline-note" id="spacing_note">Spacing inputs are active.</div>
<h3 class="section-title">Bend Geometry</h3>
<div class="input-group">
<label for="bend_factor">Bend Radius x OD</label>
<input type="text" inputmode="decimal" enterkeyhint="done" autocomplete="off" autocorrect="off" spellcheck="false" data-numeric="true" id="bend_factor" value="15" />
</div>
<div class="stat-block">
<div class="stat-row"><span>Formation Width</span><span class="stat-val" id="out_width">0 mm</span></div>
<div class="stat-row"><span>Formation Depth</span><span class="stat-val" id="out_depth">0 mm</span></div>
<div class="stat-row"><span>Burial Depth Input</span><span class="stat-val" id="out_burial">0 mm</span></div>
<div class="stat-row"><span>Indicative Trench Width</span><span class="stat-val" id="out_trench_width">0 mm</span></div>
<div class="stat-row"><span>Indicative Trench Depth</span><span class="stat-val" id="out_trench_depth">0 mm</span></div>
<div class="stat-row"><span>Applied Bend Radius</span><span class="stat-val" id="out_mbr" style="color: var(--accent-2);">0 mm</span></div>
<div class="stat-row"><span>Rows</span><span class="stat-val" id="out_rows">0</span></div>
<div class="stat-row"><span>Clear Gap Horizontal</span><span class="stat-val" id="out_gap_h">0 mm</span></div>
<div class="stat-row"><span>Clear Gap Vertical</span><span class="stat-val" id="out_gap_v">0 mm</span></div>
<div class="stat-row"><span>Approx Group CTC Horizontal</span><span class="stat-val" id="out_ctc_h">0 mm</span></div>
<div class="stat-row"><span>Approx Group CTC Vertical</span><span class="stat-val" id="out_ctc_v">0 mm</span></div>
<div class="stat-row"><span>Review Status</span><span class="stat-val" id="out_note" style="color: var(--ok);">OK</span></div>
</div>
<div class="button-row">
<button class="btn" id="export_btn" type="button">Export JSON</button>
<button class="btn btn-alt" id="copy_btn" type="button">Copy Snapshot</button>
<button class="btn" id="drawing_view_btn" type="button">Drawing View</button>
</div>
<div class="conflict-box" id="conflict_box" aria-live="polite" hidden>
<strong>Input conflicts</strong>
<ul id="conflict_list"></ul>
</div>
<div class="review-box" id="review_box" aria-live="polite" hidden>
<strong>Review points</strong>
<ul id="review_list"></ul>
</div>
<div class="assumption-box">
<strong>Standing assumptions</strong>
<ul>
<li>Within group cable spacing is assumed touching unless separately modelled.</li>
<li>Mixed service visual uses one worst case OD for all shown services and is schematic only.</li>
<li>Bend visual shows a single cable body sweep only and does not model full multi cable sweep, trench profile, duct entry, pull path or installation forces.</li>
<li>Burial depth is recorded as an indicative input only and is not design advice.</li>
<li>4-core and 5-core multicore formations are drawn as a single cable OD. Within-cable core arrangement is not modelled.</li>
</ul>
</div>
<div class="snapshot-box" id="snapshot_box"></div>
<div class="guidance-box">
<strong>Indicative burial depth guidance only</strong><br>
Use this for early geometry capture only, not final design advice.
<ul>
<li>Primary source for LV to 132kV burial depth guidance in this tool is <a href="https://g81.ukpowernetworks.co.uk/library/installation/cables/ecs-02-0019-installation-of-underground-cables-lv-to-132kv" target="_blank" rel="noopener noreferrer">UKPN ECS 02 0019 Installation of Underground Cables LV to 132kV v14.2</a>.</li>
<li>For this tool, burial depth should be read as depth to the top of duct or cable as applicable and then verified for the actual installation basis.</li>
<li>BS 7671 and ERA 69 30 give thermal rating reference depths, not utility minimum cover requirements. See the official <a href="https://electrical.theiet.org/bs-7671-18th-edition-wiring-regulations/" target="_blank" rel="noopener noreferrer">IET BS 7671 page</a>.</li>
<li>Street authority and underground apparatus context should be checked at the official <a href="https://www.gov.uk/government/publications/recording-of-underground-apparatus-in-streets-code-of-practice" target="_blank" rel="noopener noreferrer">GOV.UK underground apparatus code page</a>.</li>
<li>Street Works UK should be used as coordination context only, not as the source of the burial depth figures in this tool. See the official <a href="https://streetworks.org.uk/resources/publications/" target="_blank" rel="noopener noreferrer">Street Works UK publications page</a>.</li>
<li>DC minimum burial depth in this tool is a project default assumption only and has no normative source embedded in this release.</li>
</ul>
The user must verify safety, cover, backfill, duct arrangement, rating, separation, highway loading and protection with a competent person in accordance with the appropriate local regulation and the relevant power utility, infrastructure owner, highway authority or site designer requirements before use.
</div>
</div>
<div class="panel panel-right">
<div class="canvas-container">
<h3 style="align-self:flex-start; color: var(--accent);">Worst Case Formation Cross Section</h3>
<p class="subtle-note" style="align-self:flex-start;">
Cable group box only. Envelope width = the horizontal size of the cable group shown. Envelope depth = the vertical size of the cable group shown.
</p>
<div class="legend">
<span class="legend-item"><span class="legend-swatch" style="background:#666; border-color:#00ffff;"></span>LV AC</span>
<span class="legend-item"><span class="legend-swatch" style="background:#b87333; border-color:#ff5555;"></span>33kV AC</span>
<span class="legend-item"><span class="legend-swatch" style="background:#ffd700; border-color:#ff8800;"></span>132kV AC</span>
<span class="legend-item"><span class="legend-swatch" style="background:#777; border-color: var(--accent-2);"></span>DC</span>
</div>
<canvas id="formation_canvas" width="900" height="420" aria-label="Formation cross section visual"></canvas>
</div>
<div class="canvas-container">
<h3 style="align-self:flex-start; color: #8fd3ff;">Indicative Trench Cross Section</h3>
<p class="subtle-note" style="align-self:flex-start;">
Indicative trench size only. Trench width shown = worst case formation envelope width only. Trench depth shown = burial depth input to the top of duct or cable, plus cable formation depth. No bedding, side clearance, cover boards, duct OD, shoring or civil design is modelled.
</p>
<canvas id="trench_canvas" width="900" height="500" aria-label="Indicative trench cross section visual"></canvas>
</div>
<div class="canvas-container">
<h3 style="align-self:flex-start; color: var(--accent-2);">Single Cable Bend Sweep</h3>
<p class="subtle-note" style="align-self:flex-start;">
Single cable body sweep only. Not multi cable sweep, trench profile, duct entry or civil detail.
</p>
<canvas id="bend_canvas" width="900" height="380" aria-label="Single cable bend sweep visual"></canvas>
</div>
</div>
</div>
<script src="./data.js"></script>
<script src="./calculations.js"></script>
<script src="./rendering.js"></script>
<script src="./export.js"></script>
<script src="./ui.js"></script>
</body>
</html>Cable Route
A JavaScript module in the world folder of GlobalGrid2050 that works with cables. It routes cable (`routeCable`) and draws lines (`drawLines`).
electricalglobalgrid2050 / solar-design-studio/202609270005-site-world-v3/world/cable-route.mjs · lines 1–207 of 207 · version 2026-09-27 00:05 · pattern bendRadiusAt (shared by 3 files)
- What it does
- It calculates cables. Defines 13 functions or classes, including sub, norm, unit, turn, planSegments.
- Why it exists in the grid workflow
- Domain stage field_execution (path word 'route'): on-road and off-road field navigation to the farm gate (access gates, terrain slope, ground-bearing limits, electrical hazards), as Ventus Ltd describes its SatNav work. Domain terms in the code: cables.
- Downstream impact
- Used directly by 6 files: Design UI (globalgrid2050); Layers (globalgrid2050); Layers (globalgrid2050); Design UI (globalgrid2050); and 2 more. Reached from 7 other entry points, including Solar Design Studio — Site World Page (globalgrid2050, https://globalgrid2050.com/solar-design-studio/202609271853-site-world/); Solar Design Studio — Site World V3 Page (globalgrid2050, https://globalgrid2050.com/solar-design-studio/202609270402-site-world-v3/); Graphics Engines Open Source — Versions Page (graphics-engines-open-source, https://ventusltd.github.io/graphics-engines-open-source/web/versions/).
- What it achieves
- A buried cable laid along a plan polyline.
- Why it matters
- Imported by 6 files, including Design UI and Layers, from Graphics Engines Open Source.
- Application
- globalgrid2050 · solar-design-studio/202609270005-site-world-v3/world · JavaScript module
- Uses
- none found
- Used by
- imported by Design UI (import), imported by Layers (dynamic import), imported by Layers (dynamic import), imported by Design UI (import), imported by Design UI (import), imported by Layers (import), mentioned in Standalone (comment link)
- Produces
- routeCable
- Defines here
- sub, norm, unit, turn, planSegments, line, at, coreOffsets, routeCable, zAt, walk, bendRadiusAt, drawLines
- 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-design-studio/202609270005-site-world-v3/world/cable-route.mjs:1-207 · blob 265884bcbba42955a68f34d40a35abe73c8845cc · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: none found · domain stage: field_execution · users: EPC_contractor, landowner_planner · canonical: production_core
// Cable route: a buried cable laid along a plan polyline. Pure: no imports, no DOM, no WebGL.
// Local east (x), north (y), up (z), metres, as camera.mjs.
//
// routeCable({ points, minBendRadius, depthBelowGround, groundAt, formation, spacing, step })
// points [[x, y], ...] plan vertices (at least two)
// minBendRadius every corner is replaced by a circular arc of this radius (a fillet)
// depthBelowGround the centreline sits this far below groundAt(x, y)
// groundAt (x, y) -> ground height; default flat at 0
// formation 'flat' (three cores side by side, centre to centre = spacing) or
// 'trefoil' (three touching cores, centre to centre = spacing = core diameter)
// step sampling interval along the route, metres (default 1)
//
// A corner whose legs are too short for the requested radius is still filleted, with the largest radius the
// legs allow, and reported in violations: { index, requestedRadius, available }. Nothing is silently accepted.
// length2d is exact (straights plus arcs). length3d walks the samples with the exact plan distance between
// them and the ground-following height change, so on flat ground length3d equals length2d.
const EPS = 1e-9;
function sub(a, b) { return [a[0] - b[0], a[1] - b[1]]; }
function norm(v) { return Math.hypot(v[0], v[1]); }
function unit(v) { const l = norm(v); return [v[0] / l, v[1] / l]; }
// Signed turn from direction d1 to d2, radians, left (anticlockwise) positive.
function turn(d1, d2) { return Math.atan2(d1[0] * d2[1] - d1[1] * d2[0], d1[0] * d2[0] + d1[1] * d2[1]); }
// Build the plan geometry: straights and arcs, with fitted radii and violations.
function planSegments(pts, R) {
const n = pts.length;
const legs = [];
for (let k = 0; k < n - 1; k++) {
const v = sub(pts[k + 1], pts[k]);
legs.push({ len: norm(v), dir: norm(v) > EPS ? unit(v) : null });
}
// Requested tangent length at each vertex (0 at the ends and at straight-through vertices).
const theta = new Array(n).fill(0);
const want = new Array(n).fill(0);
for (let i = 1; i < n - 1; i++) {
const a = legs[i - 1].dir, b = legs[i].dir;
if (!a || !b) continue;
theta[i] = turn(a, b);
const half = Math.abs(theta[i]) / 2;
if (half < EPS) continue;
want[i] = Math.PI / 2 - half < EPS ? Infinity : R * Math.tan(half);
}
// Each leg must hold the tangents of both its ends; share a short leg in proportion to what each end asks.
const cap = want.slice();
for (let k = 0; k < n - 1; k++) {
const t0 = want[k], t1 = want[k + 1], len = legs[k].len;
if (t0 + t1 <= len) continue;
if (!isFinite(t0) && !isFinite(t1)) { cap[k] = Math.min(cap[k], len / 2); cap[k + 1] = Math.min(cap[k + 1], len / 2); continue; }
const f0 = !isFinite(t0) ? 1 : !isFinite(t1) ? 0 : t0 / (t0 + t1);
cap[k] = Math.min(cap[k], len * f0);
cap[k + 1] = Math.min(cap[k + 1], len * (1 - f0));
}
const violations = [];
const corners = [];
for (let i = 1; i < n - 1; i++) {
if (want[i] === 0) continue;
const half = Math.abs(theta[i]) / 2;
const reversal = Math.PI / 2 - half < EPS;
const t = reversal ? 0 : cap[i];
const r = reversal ? 0 : t / Math.tan(half);
if (r < R * (1 - 1e-9)) violations.push({ index: i, requestedRadius: R, available: r });
if (r > EPS) corners.push({ index: i, t, r, theta: theta[i] });
}
// Walk the route: straight to each tangent point, arc round, carry on.
const segs = [];
let cur = pts[0].slice(0, 2), s = 0;
const line = (a, b) => {
const len = norm(sub(b, a));
if (len < EPS) return;
segs.push({ type: 'line', a, b, dir: unit(sub(b, a)), len, s0: s, s1: s + len });
s += len;
};
for (const c of corners) {
const d1 = legs[c.index - 1].dir, d2 = legs[c.index].dir, p = pts[c.index];
const A = [p[0] - d1[0] * c.t, p[1] - d1[1] * c.t];
const B = [p[0] + d2[0] * c.t, p[1] + d2[1] * c.t];
line(cur, A);
const side = Math.sign(c.theta);
const centre = [A[0] - d1[1] * c.r * side, A[1] + d1[0] * c.r * side];
const a0 = Math.atan2(A[1] - centre[1], A[0] - centre[0]);
const len = c.r * Math.abs(c.theta);
segs.push({ type: 'arc', centre, r: c.r, a0, theta: c.theta, h0: Math.atan2(d1[1], d1[0]), len, s0: s, s1: s + len, index: c.index });
s += len;
cur = B;
}
line(cur, pts[n - 1].slice(0, 2));
return { segs, violations, length2d: s };
}
// Point and heading at parameter u in [0, 1] along a segment.
function at(seg, u) {
if (seg.type === 'line') {
return { x: seg.a[0] + (seg.b[0] - seg.a[0]) * u, y: seg.a[1] + (seg.b[1] - seg.a[1]) * u, h: Math.atan2(seg.dir[1], seg.dir[0]) };
}
const ang = seg.a0 + seg.theta * u;
return { x: seg.centre[0] + seg.r * Math.cos(ang), y: seg.centre[1] + seg.r * Math.sin(ang), h: seg.h0 + seg.theta * u };
}
// Lateral (left of travel) and vertical offsets of the three cores from the centreline.
function coreOffsets(formation, spacing) {
if (formation === 'trefoil') {
const rc = spacing / Math.sqrt(3); // circumradius of the touching triangle
return [[0, rc], [-spacing / 2, -rc / 2], [spacing / 2, -rc / 2]];
}
return [[spacing, 0], [0, 0], [-spacing, 0]];
}
export function routeCable({
points, minBendRadius = 0, depthBelowGround = 0, groundAt = () => 0,
formation = 'flat', spacing = 0, step = 1,
} = {}) {
if (!Array.isArray(points) || points.length < 2) throw Error('routeCable needs at least two points');
if (formation !== 'flat' && formation !== 'trefoil') throw Error(`unknown formation: ${formation}`);
if (!(step > 0)) throw Error('step must be positive');
const R = Math.max(0, minBendRadius);
const { segs, violations, length2d } = planSegments(points, R);
const zAt = (x, y) => groundAt(x, y) - depthBelowGround;
// Samples along the centreline: plan point, heading, chainage, and the segment they belong to.
const samples = [];
segs.forEach((seg, si) => {
let pieces = Math.max(1, Math.ceil(seg.len / step));
if (seg.type === 'arc') pieces = Math.max(pieces, Math.ceil(Math.abs(seg.theta) / (Math.PI / 36)));
for (let j = si === 0 ? 0 : 1; j <= pieces; j++) {
const u = j / pieces;
samples.push({ ...at(seg, u), s: seg.s0 + seg.len * u, seg: si });
}
});
if (!samples.length) { const p = points[0]; samples.push({ x: p[0], y: p[1], h: 0, s: 0, seg: -1 }); }
// Walk one line of samples, offset laterally by `lat` and vertically by `vert`, measuring as we go.
const walk = (lat, vert) => {
const poly = [];
let len2 = 0, len3 = 0;
for (let k = 0; k < samples.length; k++) {
const q = samples[k];
const x = q.x - Math.sin(q.h) * lat, y = q.y + Math.cos(q.h) * lat;
const z = zAt(q.x, q.y) + vert;
if (k > 0) {
const prev = samples[k - 1], seg = segs[q.seg];
// Exact plan distance: an offset arc has radius r - lat for a left turn, r + lat for a right turn.
const scale = seg.type === 'arc' ? (seg.r - Math.sign(seg.theta) * lat) / seg.r : 1;
const ds = (q.s - prev.s) * scale, dz = z - poly[k - 1][2];
len2 += ds; len3 += Math.hypot(ds, dz);
}
poly.push([x, y, z]);
}
return { polyline: poly, length2d: len2, length3d: len3 };
};
const centre = walk(0, 0);
const names = formation === 'trefoil' ? ['top', 'left', 'right'] : ['left', 'centre', 'right'];
const cores = coreOffsets(formation, spacing).map(([lat, vert], i) => {
const w = walk(lat, vert);
return { name: names[i], lateral: lat, vertical: vert, polyline: w.polyline, length2d: w.length2d, length3d: w.length3d };
});
// A core on the inside of a bend whose offset exceeds the bend radius would fold back on itself.
const maxLat = Math.max(...cores.map((c) => Math.abs(c.lateral)));
for (const seg of segs) {
if (seg.type === 'arc' && seg.r <= maxLat && !violations.some((v) => v.index === seg.index)) {
violations.push({ index: seg.index, requestedRadius: R, available: seg.r, reason: 'inner core offset exceeds bend radius' });
}
}
violations.sort((a, b) => a.index - b.index);
const bendRadiusAt = (chainage) => {
for (const seg of segs) {
if (chainage >= seg.s0 - EPS && chainage <= seg.s1 + EPS && seg.type === 'arc') return seg.r;
}
return Infinity;
};
const drawLines = ({ includeCores = true, includeCentreline = true } = {}) => {
const lines = [];
if (includeCentreline) lines.push(centre.polyline);
if (includeCores) for (const c of cores) lines.push(c.polyline);
let count = 0;
for (const l of lines) count += Math.max(0, l.length - 1);
const out = new Float32Array(count * 6);
let o = 0;
for (const l of lines) {
for (let k = 1; k < l.length; k++) {
out[o++] = l[k - 1][0]; out[o++] = l[k - 1][1]; out[o++] = l[k - 1][2];
out[o++] = l[k][0]; out[o++] = l[k][1]; out[o++] = l[k][2];
}
}
return out;
};
return {
centreline: centre.polyline,
segments: segs.map((g) => (g.type === 'arc'
? { type: 'arc', centre: g.centre, radius: g.r, turn: g.theta, s0: g.s0, s1: g.s1, index: g.index }
: { type: 'line', from: g.a, to: g.b, s0: g.s0, s1: g.s1 })),
violations,
length2d,
length3d: centre.length3d,
formation,
cores,
bendRadiusAt,
drawLines,
};
}Cable Rating
A JavaScript module in the world folder of GlobalGrid2050 that works with cables and 33kV, using IEC 60287-1-1 and IEC 60287-2-1.
electricalglobalgrid2050 / solar-design-studio/202609270220-site-world-v3/world/cable-rating.mjs · lines 1–87 of 87 · version 2026-09-27 02:20 · Not reached from any entry point (candidate for review) · pattern impedance (shared by 4 files)
- What it does
- It calculates cables and 33kV. Defines build, rating, impedance, dropPercent, sizeFor.
- Why it exists in the grid workflow
- Domain stage sub33kv_design (path word 'cable'): 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.
- Inputs & outputs
- Voltage levels named: 33kV.
- Downstream impact
- Used directly by 4 files: Block Build (globalgrid2050); Block MV (globalgrid2050); Plant Feeders (globalgrid2050); Plant Template (globalgrid2050).
- What it achieves
- It is built from the build step (`build`), the rating step (`rating`) and the impedance step (`impedance`). Continuous current rating of a 33kV single-core aluminium XLPE cable laid direct in trefoil, by the steady-state method of IEC 60287-1-1 (losses) and IEC 60287-2-1 (thermal resistances), and the size a feeder segment needs for the load it carries. Its code works with 33 kV.
- Why it matters
- Imported by 4 files, including Block Build, Block MV and Plant Feeders.
- Application
- globalgrid2050 · solar-design-studio/202609270220-site-world-v3/world · JavaScript module
- VEDIC
- PERCENT (GG2050-VEDIC-000025): Ventus Grid Engine / voltage-drop · Electrical engineering / Applied mathematics. drop_volts, nominal_volts → drop_percent
- Uses
- none found
- Used by
- imported by Block Build (import), imported by Block MV (import), imported by Plant Feeders (import), imported by Plant Template (import)
- Produces
- AL_R20, SIZES, RATING_DEFAULTS, build, rating, impedance, dropPercent, sizeFor
- Defines here
- build, rating, impedance, dropPercent, sizeFor
- 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-design-studio/202609270220-site-world-v3/world/cable-rating.mjs:1-87 · blob 8a7346b06a97064872d9da52e83234cf59ce02da · 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: unreached_review
// cable-rating.mjs: continuous current rating of a 33 kV single-core aluminium XLPE cable laid direct in trefoil,
// by the steady-state method of IEC 60287-1-1 (losses) and IEC 60287-2-1 (thermal resistances), and the size a
// feeder segment needs for the load it carries.
//
// Indicative only: a real design uses the manufacturer's data and a rating study. The cable build is estimated
// (conductor from its area, 8 mm insulation for 19/33 kV, a 35 mm2 copper wire screen) unless an OD is given.
// Soil thermal resistivity is an input: default 1.2 K.m/W native ground, ground at 15 C, conductor 90 C.
// Pure: no imports, no DOM.
// IEC 60228 class 2 aluminium, maximum DC resistance at 20 C, ohm per km.
export const AL_R20 = Object.freeze({ 35: 0.868, 50: 0.641, 70: 0.443, 95: 0.320, 120: 0.253, 150: 0.206, 185: 0.164,
240: 0.125, 300: 0.100, 400: 0.0778, 500: 0.0605, 630: 0.0469, 800: 0.0367, 1000: 0.0291 });
export const SIZES = Object.freeze(Object.keys(AL_R20).map(Number));
export const RATING_DEFAULTS = Object.freeze({
kv: 33, u0Kv: 19, freq: 50, conductorMaxC: 90, groundC: 15, soilKmW: 1.2, depthM: 0.8,
insulationMm: 8.0, semiconMm: 1.8, screenMm2: 35, screenMm: 1.0, sheathMm: 3.2,
xlpeKmW: 3.5, sheathKmW: 3.5, epsR: 2.5, tanDelta: 0.004, bonding: 'both-ends', groupFactor: 1
});
const PI = Math.PI;
// Cable build from the conductor area (mm); a given OD sets the oversheath instead.
export function build(area, p = RATING_DEFAULTS, odMm = null) {
const dc = Math.sqrt(4 * area / (PI * 0.9)); // compacted stranded conductor
const di = dc + 2 * (p.insulationMm + p.semiconMm); // over the insulation screen
const ds = di + 2 * p.screenMm; // over the wire screen
const od = odMm || ds + 2 * p.sheathMm;
return { dc, di, ds, od, sheath: (od - ds) / 2 };
}
/** rating(area, opts) -> { amps, mva, R, T1, T3, T4, lambda1, Wd, build } */
export function rating(area, opts = {}) {
const p = { ...RATING_DEFAULTS, ...opts };
if (!(area in AL_R20)) throw new Error(`cable-rating: no resistance for ${area} mm2`);
const b = build(area, p, opts.odMm || null), w = 2 * PI * p.freq;
// AC resistance at the maximum temperature: DC resistance, then skin and proximity (IEC 60287-1-1 2.1).
const rdc = AL_R20[area] / 1000 * (1 + 0.00403 * (p.conductorMaxC - 20));
const xs4 = (8 * PI * p.freq / rdc * 1e-7) ** 2, ys = xs4 / (192 + 0.8 * xs4);
const ratio = b.dc / b.od, yf = xs4 / (192 + 0.8 * xs4);
const yp = yf * ratio ** 2 * (0.312 * ratio ** 2 + 1.18 / (yf + 0.27));
const R = rdc * (1 + ys + yp);
// Dielectric loss (small at 33 kV, kept for completeness).
const C = p.epsR / (18 * Math.log(b.di / b.dc)) * 1e-9;
const Wd = w * C * (p.u0Kv * 1000) ** 2 * p.tanDelta;
// Screen loss factor: bonded both ends, trefoil, circulating current (IEC 60287-1-1 2.3.1).
const rs = 0.524 / 1000 * (35 / p.screenMm2) * (1 + 0.00393 * 50);
const dMean = (b.di + b.ds) / 2, X = 2 * w * 1e-7 * Math.log(2 * b.od / dMean);
const lambda1 = p.bonding === 'both-ends' ? rs / R / (1 + (rs / X) ** 2) : 0;
// Thermal resistances (IEC 60287-2-1): insulation, oversheath, and ground for touching trefoil.
const T1 = p.xlpeKmW / (2 * PI) * Math.log(1 + 2 * (p.insulationMm + p.semiconMm) / b.dc);
const T3 = p.sheathKmW / (2 * PI) * Math.log(1 + 2 * b.sheath / b.ds);
const L = p.depthM + b.od / 1000 * (0.5 + Math.sqrt(3) / 4), u = 2 * L / (b.od / 1000);
const T4 = 1.5 / PI * p.soilKmW * (Math.log(2 * u) - 0.630);
const dT = p.conductorMaxC - p.groundC - Wd * (0.5 * T1 + T3 + T4);
const amps = Math.sqrt(dT / (R * T1 + R * (1 + lambda1) * (T3 + T4))) * p.groupFactor;
return { area, amps, mva: Math.sqrt(3) * p.kv * amps / 1000, R, T1, T3, T4, lambda1, Wd, build: b };
}
/** Series impedance per metre of a trefoil circuit: { r, x } ohm/m at the rated temperature. */
export function impedance(area, opts = {}) {
const p = { ...RATING_DEFAULTS, ...opts }, rr = rating(area, p);
const gmr = 0.39 * rr.build.dc, s = rr.build.od;
return { r: rr.R, x: 2 * PI * p.freq * 2e-7 * Math.log(s / gmr) };
}
/** Voltage drop in % over a length for a three-phase load in MVA at power factor pf. */
export function dropPercent(area, lengthM, mva, { pf = 0.95, ...opts } = {}) {
const p = { ...RATING_DEFAULTS, ...opts }, z = impedance(area, p);
const I = mva * 1e6 / (Math.sqrt(3) * p.kv * 1000), sin = Math.sqrt(1 - pf * pf);
return Math.sqrt(3) * I * lengthM * (z.r * pf + z.x * sin) / (p.kv * 1000) * 100;
}
/**
* sizeFor(mva, opts) -> the smallest size whose rating carries the load: { area, amps, loadAmps, utilisation }
* or null when even the largest will not (the load needs another feeder).
*/
export function sizeFor(mva, opts = {}) {
const p = { ...RATING_DEFAULTS, ...opts }, loadAmps = mva * 1e6 / (Math.sqrt(3) * p.kv * 1000);
const min = opts.minArea || 0;
for (const a of SIZES) {
if (a < min) continue;
const r = rating(a, p);
if (r.amps >= loadAmps) return { area: a, amps: r.amps, loadAmps, utilisation: loadAmps / r.amps };
}
return null;
}