In this section
- AC Trenches Smoke test · energy-transition-simulator / tests/ac-trenches-smoke.cjs lines 1–150
- Trench Measure test · energy-transition-simulator / tests/trench-measure.cjs lines 1–110
- Cable Cases electrical · faraday / bench/cable_cases.py lines 1–71
- Data Core other · globalgrid2050 / cable_geometry/data-core.js lines 1–316
- Data LV other · globalgrid2050 / cable_geometry/data-lv.js lines 1–39
AC Trenches Smoke
A JavaScript module in the tests folder of Energy Transition Simulator that tests AC trenches fixture, cables and the Renewable Energy Planning Database (REPD) register.
testenergy-transition-simulator / tests/ac-trenches-smoke.cjs · lines 1–150 of 150 · Not reached from any entry point (candidate for review)
- What it does
- It tests AC trenches fixture, cables and the REPD register. Defines el, near, mper. Uses libraries fs, path, vm. Side effects: changes the web page (DOM); reads or writes files; starts processes.
- 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, the REPD register.
- Inputs & outputs
- In: JSON file ac-trenches-6502.json; JSON file ac-trenches-fixture.json. Coordinate systems named: WGS84 / EPSG:4326.
- What it achieves
- It is built from the near step (`near`) and the mper step (`mper`). Smoke check for `prototype/mod/ac-trenches.js` v2, with a synthetic fixture (no network, no browser).
- Why it matters
- No other file in the estate was found to import it.
- Application
- energy-transition-simulator · tests · JavaScript module
- Uses
- fs, path, vm
- Used by
- none found
- Produces
- el, near, mper
- Defines here
- el, near, mper
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- energy-transition-simulator@a165ce6d56cb22271828874d68d570e8fa5e428a tests/ac-trenches-smoke.cjs:1-150 · blob 1f6672912c291777cbd5bbf8755b8ab638386d2a · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, filesystem, process · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: unreached_review
// Smoke check for prototype/mod/ac-trenches.js v2, with a synthetic fixture (no network, no browser).
// Runs the module's own maths in a VM and checks it against independent numbers:
// - duct rules against the duct scout's worked values (Southwire jam ratio bands, 40 % fill, clearance; cited, not copied):
// 31.5 mm singles in 125 SDR17 (ID 110.2): J 3.498 'very small', fill 24.5 %, clearance 66.1 mm, cradled;
// 37.4 mm armoured in 96.5/90: J 2.406 'small', clearance 12.4 mm, triangular;
// - the live duct pick (125 SDR17 at the default OD), the governing bend (duct 2.5 m; the cable MBR governs and flags past it);
// - trench widths measured back from the drawn quads with WGS84 radii (within 1 cm), layers and width flags;
// - bend and entry flags recomputed live when the MBR is edited; section geometry (cables inside their duct);
// - on the REAL data file: 28 routes (or recorded unreached inverters) and 28 holes per station in every case, no names,
// no drive paths, neutral labels, the private layer never fetched without ?private=1 on a local server.
const fs = require('fs'), path = require('path'), vm = require('vm');
const ROOT = path.join(__dirname, '..'), MOD = path.join(ROOT, 'prototype', 'mod');
const results = []; const check = (name, ok, ev) => results.push({ name, ok: !!ok, ev: String(ev).slice(0, 220) });
const layers = new Map(), sources = new Map();
const map = { on() {}, once() {}, getLayer: id => layers.get(id), addLayer: (l) => layers.set(l.id, l), removeLayer: id => layers.delete(id), getSource: id => sources.get(id),
addSource: (id, s) => sources.set(id, { ...s, setData(d) { this.data = d; } }), removeSource: id => sources.delete(id), setPaintProperty() {}, getZoom: () => 15, jumpTo() {},
addControl() {}, removeControl() {}, getBounds: () => ({ contains: () => true }), queryTerrainElevation: () => 0 };
const PF = { placeKey: (lat, lon) => ({ lat, lon }), toLocal: (an, lat, lon) => ({ x: (lon - an.lon) * 69000, y: (lat - an.lat) * 111000 }), toMercator: () => ({ x: 0, y: 0, z: 0 }),
wireBuffer: (an, lines) => new Float32Array(lines.length * 6) };
let infoText = '', fetched = [];
const win = { SIM: { map, PF, blocks: [], addButton: () => ({ classList: { toggle() {} } }), info(t) { infoText = t; }, repaint() {} } };
const realText = fs.readFileSync(path.join(MOD, 'ac-trenches-6502.json'), 'utf8'), real = JSON.parse(realText);
const el = () => ({ style: {}, dataset: {}, classList: { toggle() {}, add() {} }, append() {}, appendChild() {}, querySelectorAll: () => [], querySelector: () => null, set innerHTML(v) {} });
const ctx = { window: win, document: { currentScript: null, createElement: el, body: { appendChild() {} }, activeElement: null }, location: { search: '', hostname: 'example.org' },
URLSearchParams, setTimeout, console, performance: { now: () => 0 }, requestAnimationFrame: () => 1, cancelAnimationFrame() {},
fetch: async (u) => { fetched.push(String(u)); return { ok: true, json: async () => JSON.parse(realText) }; },
maplibregl: { ScaleControl: class {}, Marker: class { setLngLat() { return this; } addTo() { return this; } remove() {} } } };
vm.createContext(ctx); vm.runInContext(fs.readFileSync(path.join(MOD, 'ac-trenches.js'), 'utf8'), ctx);
const A = win.__acTrenches; check('module attaches window.__acTrenches', !!A, typeof A);
const fx = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures', 'ac-trenches-fixture.json'), 'utf8'));
const near = (a, b, t) => Math.abs(a - b) <= t;
// ---- duct rules against the scout's worked values ----
let c = A.ductCheck(110.2, 31.5);
check('125 SDR17 with 31.5 mm singles: J 3.498 very small, fill 24.5 %, clearance 66.1 mm, cradled', near(c.J, 3.498, 0.001) && c.band === 'very small' && near(c.fill, 0.245, 0.001) && near(c.cl, 66.1, 0.1) && c.config === 'cradled' && c.preferred, `${c.J.toFixed(3)} ${c.band} ${(c.fill * 100).toFixed(1)} ${c.cl.toFixed(1)} ${c.config}`);
c = A.ductCheck(90.0, 37.4);
check('96.5/90 with 37.4 mm armoured: J 2.406 small, clearance 12.4 mm, triangular, fails fill', near(c.J, 2.406, 0.001) && c.band === 'small' && near(c.cl, 12.4, 0.1) && c.config === 'triangular' && !c.pass, `${c.J.toFixed(3)} ${c.band} ${c.cl.toFixed(1)} ${(c.fill * 100).toFixed(1)} %`);
check('jam bands: 2.75 significant, 2.95 moderate, 3.1 small, 3.3 very small', A.jamBand(2.75) === 'significant' && A.jamBand(2.95) === 'moderate' && A.jamBand(3.1) === 'small' && A.jamBand(3.3) === 'very small', [2.75, 2.95, 3.1, 3.3].map(A.jamBand).join(','));
const pk = A.pickDuct(fx.duct_table, 31.5);
check('default OD 31.5 mm picks 125 SDR17 (ID 110.2), the scout default', pk.duct && pk.duct.id === 'emt_c1_125_sdr17', pk.duct && pk.duct.id);
const pk2 = A.pickDuct(fx.duct_table, 36.0);
check('a larger OD (36 mm) re-sizes the duct upward', pk2.duct && pk2.duct.id_mm > 110.2, pk2.duct && pk2.duct.id);
check('US products are never picked', fx.duct_table.filter(t => !t.uk).every(t => t.id !== pk.duct.id && t.id !== (pk2.duct || {}).id), 'uk only');
// ---- governing bend ----
let pp = A.params(fx, 'A');
check('A: governing bend = duct 2.5 m (cable MBR 472 mm), no MBR flag', near(pp.R, 2.5, 1e-9) && pp.governs === 'duct bend' && !pp.mbrFlag, `${pp.R} ${pp.governs}`);
const ppB = A.params(fx, 'B');
check('B: governing bend = catalogue MBR 0.449 m, OD 37.40 mm', near(ppB.R, 0.449, 1e-9) && near(ppB.od, 0.0374, 1e-9), `${ppB.R} ${ppB.od}`);
// ---- widths and layers ----
check('A width n=7 = 7 x 0.125 + 6 x 0.1 + 0.2 = 1.675 m', near(A.width(pp, 7), 1.675, 1e-9), A.width(pp, 7));
check('B width n=7 (21 cables, one diameter clear) = 21 x 0.0374 + 20 x 0.0374 + 0.2 = 1.7334 m', near(A.width(ppB, 7), 1.7334, 1e-9), A.width(ppB, 7));
const l14 = A.layersFor(pp, 14, 1.2);
check('A n=14 in a 1.2 m corridor: 3 layers still 1.225 m, flagged', l14.L === 3 && l14.fault, JSON.stringify(l14));
check('A n=14 in a 2.0 m corridor: 2 layers, 1.675 m', A.layersFor(pp, 14, 2.0).L === 2 && !A.layersFor(pp, 14, 2.0).fault, JSON.stringify(A.layersFor(pp, 14, 2.0)));
// ---- plan quads measured back with WGS84 meridian / prime-vertical radii (an independent metric) ----
const a_ = 6378137, f_ = 1 / 298.257223563, e2 = f_ * (2 - f_);
const mper = lat => { const s = Math.sin(lat * Math.PI / 180) ** 2; return { x: a_ / Math.sqrt(1 - e2 * s) * Math.cos(lat * Math.PI / 180) * Math.PI / 180, y: a_ * (1 - e2) / (1 - e2 * s) ** 1.5 * Math.PI / 180 }; };
for (const [i, s] of [['A', '4'], ['B', '4']]) {
const g = A.planGeo(fx, i, s), quads = g.trench.features.filter(f => f.properties.kind === 'quad'), P2 = A.params(fx, i);
let worst = 0; for (const ft of quads) { const q = ft.geometry.coordinates[0], m = mper(q[0][1]), wd = Math.hypot((q[0][0] - q[3][0]) * m.x, (q[0][1] - q[3][1]) * m.y); worst = Math.max(worst, Math.abs(wd - A.width(P2, ft.properties.n, ft.properties.L))); }
check(`${i}${s}: every drawn quad is its formula width within 1 cm (measured back)`, quads.length >= 3 && worst < 0.01, `${quads.length} quads, worst ${worst.toFixed(4)} m`);
check(`${i}${s}: 28 holes drawn (7 per side)`, g.holes.features.length === 28, g.holes.features.length);
check(`${i}${s}: road drawn as centre + two edges; one ducted crossing marked`, g.roads.features.length === 3 && g.cross.features.length === 1, `${g.roads.features.length} ${g.cross.features.length}`);
}
// ---- live bend and entry flags ----
let ev = A.evaluate(fx, 'A', '4');
check('A4 at defaults: 1 bend tighter than 2.5 m, 8 entries short of 1.0 + 2.5 m', ev.bendFlags.length === 1 && ev.entryFlags === 8, `${ev.bendFlags.length} ${ev.entryFlags}`);
check('A4: the n=14 edge in a 1.2 m corridor is flagged (width)', ev.faults === 1, ev.faults);
const evB = A.evaluate(fx, 'B', '4');
check('B4 at defaults: 0 bend flags at 0.449 m, 0 short entries', evB.bendFlags.length === 0 && evB.entryFlags === 0, `${evB.bendFlags.length} ${evB.entryFlags}`);
A.set('A', 31.5, 3500); // edit the MBR above the duct bend: the cable governs, flags rise (set() also redraws; doc not loaded yet, guarded)
pp = A.params(fx, 'A'); ev = A.evaluate(fx, 'A', '4');
check('A MBR edited to 3500 mm: cable MBR governs, MBR flag on, 2 bend flags', pp.governs === 'cable MBR' && pp.mbrFlag && near(pp.R, 3.5, 1e-9) && ev.bendFlags.length === 2, `${pp.governs} ${pp.R} ${ev.bendFlags.length}`);
A.set('A', 31.5, 472);
// ---- section ----
const sec = A.sectionOf(A.params(fx, 'A'), 7);
const inside = sec.items.every(it => it.cables.every(([x, z]) => Math.hypot(x - it.x, z - it.z) + it.cr <= it.ri + 1e-9));
check('A section: 7 ducts, 21 cables, every cable inside its duct ID', sec.items.length === 7 && sec.items.reduce((t, it) => t + it.cables.length, 0) === 21 && inside, `${sec.items.length} ${inside}`);
check('A section: ducts inside the trench walls', sec.items.every(it => Math.abs(it.x) + it.r <= sec.W / 2 - 0.1 + 1e-9), sec.W);
const secB = A.sectionOf(A.params(fx, 'B'), 7);
check('B section: 21 cables in one flat layer, inside the walls', secB.items.length === 21 && new Set(secB.items.map(i => i.z.toFixed(4))).size === 1 && secB.items.every(it => Math.abs(it.x) + it.r <= secB.W / 2 - 0.1 + 1e-9), secB.items.length);
check('section SVG carries its width', /data-width-m="1.675"/.test(A.sectionSVG(A.params(fx, 'A'), 7)), 'svg');
check('piles: 12 per station (3 x 2 under each of two units)', A.pilesOf(fx.bunds[0], fx.installations.B.piles, fx).length === 12, A.pilesOf(fx.bunds[0], fx.installations.B.piles, fx).length);
const pt = A.partial([[0, 0], [10, 0], [10, 10]], 0.75);
check('partial(): 75 % of a 20 m polyline ends 5 m up the second leg', pt.length === 3 && near(pt[2][1], 5, 1e-9), JSON.stringify(pt));
// ---- the real data file ----
(async () => {
check('real file: keyed by REPD ref, no name/site field', real.repd === 'REPD 6502' && !('name' in real) && !('site' in real), real.repd);
check('real file: no drive paths, user paths or imagery URLs', !/[A-Za-z]:[\\/]|Users[\\/]|\.jpg|\.png|arcgisonline|private[\\/]/i.test(realText), 'scan');
check('real file: neutral labels (never "as built", never a verdict on a site)', !/as[- ]built|non-?compliant|defect|poor(ly)? (built|installed)/i.test(realText), 'scan');
const src = fs.readFileSync(path.join(MOD, 'ac-trenches.js'), 'utf8');
check('module source: no "as built" anywhere on screen', !/as[- ]built/i.test(src), 'scan');
check('real file: 8 cases (A/B x 1-4 sides)', ['A1', 'A2', 'A3', 'A4', 'B1', 'B2', 'B3', 'B4'].every(k => real.cases[k]), Object.keys(real.cases).join(','));
const bad = []; let unreached = 0;
for (const [k, cs] of Object.entries(real.cases)) {
for (const s of cs.stations) { if (s.routes + s.unreachable !== 28) bad.push(`${k} ${s.id} ${s.routes}+${s.unreachable}`); unreached += s.unreachable; }
const holes = {}; for (const p of cs.ports) holes[p.si] = (holes[p.si] || 0) + p.nh;
for (const s of cs.stations) if (holes[s.si] !== 28) bad.push(`${k} ${s.id} holes ${holes[s.si]}`);
if (cs.stations.length !== 24) bad.push(`${k} stations ${cs.stations.length}`);
}
check('real file: every station in every case has 28 inverters routed or recorded unreached, and 28 holes', bad.length === 0, bad.slice(0, 4).join('; ') + ` (unreached recorded: ${unreached})`);
check('real file: units drawn only where two were seen (class A)', real.bunds.every(b => (b.units_to_draw === 2) === (b.cls === 'A')), real.bunds.map(b => b.cls + b.units_to_draw).join(''));
check('real file: chain centrelines over rows < 2 m in every case (routes on free ground)', Object.values(real.cases).every(c => c.totals.chain_rows_m < 2), Object.values(real.cases).map(c => c.totals.chain_rows_m).join(','));
// ---- FIX ROUND 1 (witnesses v2) ----
const OWN = /\bowner\b/i;
check('privacy: no "owner" in the real data file, the fixture or the module source', !OWN.test(realText) && !OWN.test(fs.readFileSync(path.join(__dirname, 'fixtures', 'ac-trenches-fixture.json'), 'utf8')) && !OWN.test(fs.readFileSync(path.join(MOD, 'ac-trenches.js'), 'utf8')), 'scan');
const rc = Object.entries(real.cases).map(([k, c]) => { const T = c.totals, list = c.stations.flatMap(s => s.tab_runs || []);
return { k, T, lc: list.filter(r => r[2] === 'c').length, la: list.filter(r => r[2] === 'a').length, img: c.stations.reduce((t, s) => t + (s.seam_img_runs || []).length, 0), pan: c.stations.flatMap(s => s.panel_runs || []), dng: c.stations.flatMap(s => s.dark_runs || []) }; });
check('closed table mask: chain runs > 1 m are 0, or every one is listed per station', rc.every(r => r.T.rows_crossed === r.lc && r.T.rows_crossed_entry === r.la), rc.map(r => `${r.k} ${r.T.rows_crossed}/${r.lc} ${r.T.rows_crossed_entry}/${r.la}`).join(' '));
check('imagery test: chain runs >= 1.5 m inside visible panel are 0, or listed per station', rc.every(r => r.T.seam_img_runs === r.img), rc.map(r => `${r.k} ${r.T.seam_img_runs}`).join(' '));
check('rows crossed on screen = JSON centre_rows_m less the corner clips (chains + entry legs), every case', rc.every(r => Math.abs(r.T.centre_rows_m - r.T.clip_m - r.T.rows_crossed_m - r.T.rows_crossed_entry_m) < 0.15), rc.map(r => `${r.k} ${r.T.centre_rows_m}-${r.T.clip_m}=${r.T.rows_crossed_m}+${r.T.rows_crossed_entry_m}`).join(' '));
// ---- FIX ROUND 2 (witnesses v2, re-check r1) ----
check('unmasked panel-coloured ground: chain runs >= 2 m are 0, or listed per station and the list equals the count, every case', rc.every(r => typeof r.T.panel_runs === 'number' && r.T.panel_runs === r.pan.length && r.pan.every(x => x[2] >= 2 - 1e-9) && Math.abs(r.T.panel_m - r.pan.reduce((t, x) => t + x[2], 0)) < 0.05), rc.map(r => `${r.k} ${r.T.panel_runs}/${r.pan.length}`).join(' '));
check('unmasked dark non-green ground: chain runs > 1 m are 0, or listed per station and the list equals the count, every case', rc.every(r => typeof r.T.dark_runs === 'number' && r.T.dark_runs === r.dng.length && r.dng.every(x => x[2] > 1) && Math.abs(r.T.dark_m - r.dng.reduce((t, x) => t + x[2], 0)) < 0.05), rc.map(r => `${r.k} ${r.T.dark_runs}/${r.dng.length}`).join(' '));
const hb = [];
for (const [k, c] of Object.entries(real.cases)) for (const p of c.ports) {
const w = real.bunds[p.si].walls.find(x => x.side === p.side), t = p.t || [];
if (t.length !== p.nh || t.some((x, i) => !(x > 0 && x < 1) || (i && (x - t[i - 1]) * w.len < 0.3 - 1e-6))) hb.push(`${k} ${real.bunds[p.si].id}${p.side}`);
}
check('holes: ports.t gives every hole inside its wall, in order, at least 0.30 m apart', hb.length === 0, hb.slice(0, 4).join('; ') || 'all ports');
const moved = real.cases.A4.ports.find(p => p.t.some((x, h) => Math.abs(x - (h + 0.5) / p.nh) > 1e-4));
check('holes drawn at ports.t (holesOf follows the data file where the holes are not evenly spread)', !moved || (() => { const w = real.bunds[moved.si].walls.find(x => x.side === moved.side), H = A.holesOf ? A.holesOf(real, real.cases.A4).find(h => h.si === moved.si && h.side === moved.side && h.i === 1) : null; return H && Math.abs(H.en[0] - (w.p0[0] + (w.p1[0] - w.p0[0]) * moved.t[0])) < 1e-6; … [line shortened here: 477 characters; full line on GitHub]
const offend = rc.map(r => { const e = A.evaluate(real, r.k[0], r.k[1]).E.filter(x => x.rowx); return { k: r.k, n: e.length, ok: e.every(x => x.fault), need: r.T.rows_crossed + r.T.rows_crossed_entry + r.T.seam_img_runs + r.T.panel_runs + r.T.dark_runs }; });
check('every row-crossing edge is drawn in the fault colour (and there is one wherever the JSON counts one)', offend.every(o => o.ok && (o.need === 0 || o.n > 0)), offend.map(o => `${o.k} ${o.n}`).join(' '));
const bl = rc.map(r => ({ k: r.k, live: A.evaluate(real, r.k[0], r.k[1]).bendFlags.length, json: r.T.bend_flags }));
check('live bend count at defaults equals the table, every case', bl.every(b => b.live === b.json), bl.map(b => `${b.k} ${b.live}/${b.json}`).join(' '));
check('widest station: cases.X.widest and totals.widest agree, every case', Object.values(real.cases).every(c => real.bunds[c.widest.si].id === c.totals.widest.station && c.widest.n === c.totals.widest.n), Object.entries(real.cases).map(([k, c]) => `${k} ${real.bunds[c.widest.si].id}/${c.totals.widest.station}`).join(' '));
check('live widest station equals totals.widest, every case', rc.every(r => real.bunds[A.evaluate(real, r.k[0], r.k[1]).widest.si].id === r.T.widest.station), rc.map(r => real.bunds[A.evaluate(real, r.k[0], r.k[1]).widest.si].id).join(','));
await A.toggle(); // through the stub map: plan layers, 3D wires and the info line, no private fetch
check('toggle: plan layers added (trench, holes, roads, crossings, bends)', ['act-trench', 'act-holes', 'act-roads', 'act-cross', 'act-bends'].every(id => layers.has(id)), [...layers.keys()].join(','));
check('toggle: 3D station wires built', A.state().wires.length === 6 && A.state().wires.some(w => w.n > 0), JSON.stringify(A.state().wires));
check('info line: MODEL, illustrative, derating NOT assessed, no "as built"', /MODEL/.test(infoText) && /illustrative/.test(infoText) && /Derating NOT assessed/.test(infoText) && !/as built/i.test(infoText), infoText.slice(0, 120));
check('info line: no "owner"', !OWN.test(infoText), 'scan');
await A.select('A', '4');
const T4 = real.cases.A4.totals, want = T4.rows_crossed_entry ? `${T4.rows_crossed_entry} entry legs (${T4.rows_crossed_entry_m} m) at ${T4.entry_crossed_stations} stations` : 'Rows crossed: 0';
check('info line A4 carries the rows-crossed line from the JSON', infoText.includes(want) && !OWN.test(infoText), want);
const want2 = T4.panel_runs || T4.dark_runs ? 'NOT PROVEN CLEAR: ' + [T4.panel_runs ? `${T4.panel_runs} chain runs of 2 m or more (${T4.panel_m} m) on unmasked panel-coloured ground at ${T4.panel_stations} stations` : '', T4.dark_runs ? `${T4.dark_runs} chain runs over 1 m (${T4.dark_m} m) on unmasked dark non-green ground at ${T4.dark_stations} stations` : ''].filter(Boolean).join('; ') : 'Chai … [line shortened here: 453 characters; full line on GitHub]
check('info line A4 carries the unmasked-ground runs from the JSON whenever they are not 0', infoText.includes(want2), want2);
check('info line: track contacts relabelled (crossings or edge grazes) with true crossings apart', /Track contacts \d+ \(crossings or edge grazes; track mask \+\/-2-6 m\); true crossings \d+, ducted/.test(infoText) && !/road crossings \d+ \(ducted\)/.test(infoText), (infoText.match(/Track contacts[^.]*/) || [''])[0]);
await A.set('A', 40, 600);
check('duct OD vs the assumed 160 mm hole: flagged when the live duct reaches it', /FLAG: duct OD \d+ mm (exceeds|equals) the assumed 160 mm hole/.test(infoText), (infoText.match(/FLAG: duct OD[^.]*/) || ['none: ' + (infoText.match(/Duct [^;]*/) || [''])[0]])[0]);
await A.set('A', 31.5, 472);
check('private layer NOT fetched without ?private=1 on a local server', fetched.every(u => !/sld-layer/.test(u)) && !A.state().priv, fetched.join(','));
await A.select('B', '1');
check('select B1: piles and units drawn at the focused station', A.state().inst === 'B' && A.state().wires.find(w => w.kind === 'piles').n > 0, JSON.stringify(A.state().wires));
const pass = results.filter(r => r.ok).length;
for (const r of results) console.log(`${r.ok ? 'PASS' : 'FAIL'} ${r.name} [${r.ev}]`);
console.log(`\nac-trenches smoke: ${pass}/${results.length}`); process.exit(pass === results.length ? 0 : 1);
})().catch(e => { console.error(e); process.exit(2); });Trench Measure
A JavaScript module in the tests folder of Energy Transition Simulator that tests 132kV and 33kV. It is built from the launch step (`launch`).
testenergy-transition-simulator / tests/trench-measure.cjs · lines 1–110 of 110 · Not reached from any entry point (candidate for review) · pattern launch (shared by 5 files)
- What it does
- It tests 132kV and 33kV. Defines launch. Uses libraries http, fs, path, playwright. Side effects: changes the web page (DOM); reads or writes files; starts processes.
- Why it exists in the grid workflow
- Domain stage sub33kv_design (path word 'trench'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary. Domain terms in the code: 132kV, 33kV.
- Inputs & outputs
- In: JSON file index.json. Out: JSON file results.json. Voltage levels named: 132kV, 33kV.
- What it achieves
- Trench-measure test: serves `prototype/` with a scratch module list (the page's own `index.json` plus trench-measure), opens `overlay.html`, runs connect-here (straight route, so no road router is called), draws the trench with the cited section. Its code works with 132 kV and 33 kV.
- Why it matters
- No other file in the estate was found to import it.
- Application
- energy-transition-simulator · tests · JavaScript module
- Uses
- http, fs, path, playwright
- Used by
- none found
- Produces
- launch
- Defines here
- launch
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- energy-transition-simulator@a165ce6d56cb22271828874d68d570e8fa5e428a tests/trench-measure.cjs:1-110 · blob 0f014a90a6391347f9cb38da51c35d09c0aa9cdc · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, filesystem, process · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: unreached_review
// Trench-measure test: serves prototype/ with a scratch module list (the page's own index.json plus trench-measure),
// opens overlay.html, runs connect-here (straight route, so no road router is called), draws the trench with the
// cited section, and reads the drawn geometry back from the GPU buffers: width, depth, cover, phase and circuit
// spacing must equal the typed or cited values within 1 cm. Also: a typed section, a refused section that does
// not fit, and a negative control (a vertex moved 2 cm must FAIL the check). Screenshots to test-output/trench-measure
// (or SHOTS=dir). CHROME_LAUNCHER=path/to/launcher.cjs uses a shared launcher; otherwise playwright's Chrome.
const http = require('http'), fs = require('fs'), path = require('path');
const ROOT = path.join(__dirname, '..', 'prototype');
const OUT = process.env.SHOTS || path.join(__dirname, '..', 'test-output', 'trench-measure');
const TYPES = { '.html': 'text/html', '.js': 'text/javascript', '.mjs': 'text/javascript', '.json': 'application/json', '.bin': 'application/octet-stream' };
fs.mkdirSync(OUT, { recursive: true });
const server = http.createServer((q, s) => {
const rel = decodeURIComponent(q.url.split('?')[0]).replace(/^\/+/, '') || 'overlay.html';
if (rel === 'mod/index.json') { // scratch overlay: the page's module list plus this lane's module
const list = JSON.parse(fs.readFileSync(path.join(ROOT, 'mod', 'index.json'), 'utf8'));
if (!list.includes('trench-measure')) list.push('trench-measure');
s.writeHead(200, { 'Content-Type': 'application/json' }); return s.end(JSON.stringify(list));
}
const f = path.join(ROOT, rel);
if (!f.startsWith(ROOT) || !fs.existsSync(f) || fs.statSync(f).isDirectory()) { s.writeHead(404); return s.end(); }
s.writeHead(200, { 'Content-Type': TYPES[path.extname(f)] || 'application/octet-stream' }); fs.createReadStream(f).pipe(s);
});
const results = []; const check = (name, ok, evidence) => results.push({ name, ok: !!ok, evidence: String(evidence).slice(0, 400) });
const launch = () => process.env.CHROME_LAUNCHER ? require(process.env.CHROME_LAUNCHER).launch()
: require('playwright').chromium.launch({ channel: process.env.CI ? undefined : 'chrome', args: process.env.CI ? ['--use-angle=swiftshader', '--enable-unsafe-swiftshader'] : ['--use-angle=d3d11', '--enable-gpu', '--ignore-gpu-blocklist'] });
const LAT = +(process.env.TLAT || 51.215), LON = +(process.env.TLON || -1.78);
(async () => {
await new Promise(r => server.listen(0, '127.0.0.1', r));
const base = `http://127.0.0.1:${server.address().port}/overlay.html`;
const b = await launch();
const p = await b.newPage({ viewport: { width: 1280, height: 800 } });
const errs = []; p.on('pageerror', e => errs.push(e.message));
await p.goto(`${base}?lat=${LAT}&lon=${LON}&connect=1&croad=0&trench=1`, { waitUntil: 'load' });
await p.waitForFunction(() => window.__trench && /Trench (check|:)/.test(window.__trench.lastText || ''), null, { timeout: 90000 }).catch(() => {});
await p.waitForTimeout(2500);
const first = await p.evaluate(() => ({ text: window.__trench && window.__trench.lastText, c: window.__connect && { kv: window.__connect.kv, n: window.__connect.n, route_m: window.__connect.route_m } }));
check('connect-here route exists', first.c && first.c.route_m > 0, JSON.stringify(first.c));
const auto = await p.evaluate(() => window.__trench.check());
const FARM = { 33: { 1: '33kv-1-agri', 2: '33kv-2-agri' }, 132: { 1: '132kv-1-dno@farmland', 2: '132kv-2@farmland' } };
check('trench auto: farmland section drawn (default land, labelled assumed)', auto.section === (FARM[first.c.kv] || {})[first.c.n] && auto.land === 'farmland' && auto.land_prov === 'assumed', `${auto.section} for ${first.c.kv} kV x ${first.c.n}, land ${auto.land} (${auto.land_prov})`);
const cov = auto.rows.find(r => r.what === 'cover');
check('trench auto on farmland: cover 0.91 m (S1 Table 5.4.1), cited', cov && cov.value_m === 0.91 && cov.prov === 'cited' && cov.pass, JSON.stringify(cov));
check('the read-back check is named "consistency"', auto.name === 'consistency' && /^Trench consistency (PASS|FAIL)/.test(auto.text) && /not a site survey/.test(auto.text), auto.text.slice(0, 120));
check('trench auto: drawn = cited within 1 cm at every rib', auto.ok && auto.ribs > 0, auto.text);
for (const r of auto.rows) check(` ${r.what} ${r.value_m} m (${r.prov})`, r.pass, `worst ${(r.worst_err_m * 1000).toFixed(3)} mm`);
await p.screenshot({ path: path.join(OUT, '1-route-overview.png') });
// Walk to the section nearest the route's middle ("trench go": zoom 22, looking along the trench, true scale).
const rib = await p.evaluate(() => { const r = window.__trench.route(), i = Math.floor(r.length / 2); return r[i]; });
await p.evaluate(([lon, lat]) => window.SIM.map.jumpTo({ center: [lon, lat] }), rib);
const go = await p.evaluate(() => window.__trench.cmd('trench go'));
check('trench go: walks to a section at zoom 22', /looking along the trench/.test(go) , go);
await p.waitForTimeout(4000);
// On software WebGL (CI) the ease to zoom 22 is still running at 4 s; wait for the map to settle, as a player would.
await p.waitForFunction(() => !window.SIM.map.isMoving(), null, { timeout: 60000 }).catch(() => {});
await p.evaluate(() => window.SIM.map.fire('moveend')); await p.waitForTimeout(800);
check('X-ray lifts the zoom limit to 22', await p.evaluate(() => window.SIM.map.getZoom() > 21.9), await p.evaluate(() => window.SIM.map.getZoom()));
await p.screenshot({ path: path.join(OUT, '2-xray-walk-z22.png') });
await p.evaluate(() => window.SIM.map.jumpTo({ pitch: 0, bearing: 0 }));
await p.waitForTimeout(3000);
await p.screenshot({ path: path.join(OUT, '3-xray-plan-z22.png') });
// Other land (typed): the catalogue's 0.90 m (132 kV) or 0.75 m (33 kV) section, labelled typed.
const oth = await p.evaluate(async () => { await window.__trench.cmd('trench auto other'); return window.__trench.consistency(); });
const ocov = oth.rows.find(r => r.what === 'cover');
check('trench auto other: other-land cover, land typed', oth.ok && oth.land === 'other' && oth.land_prov === 'typed' && ocov.value_m < 0.91 && !/@farmland/.test(oth.section), `${oth.section} cover ${ocov.value_m} (${ocov.prov})`);
const fb = await p.evaluate(async () => { await window.__trench.cmd('trench auto farmland'); await window.__trench.cmd('trench go'); return window.__trench.consistency(); });
check('trench auto farmland: back to 0.91 m, land typed', fb.ok && fb.rows.find(r => r.what === 'cover').value_m === 0.91 && fb.land_prov === 'typed', fb.section);
await p.waitForTimeout(3000); await p.evaluate(() => window.SIM.map.fire('moveend')); await p.waitForTimeout(800);
const foot = await p.evaluate(() => document.getElementById('trench-foot').textContent);
check('panel shows the land class and "Consistency", no "typical"', /Land: farmland \[typed\]/.test(foot) && /Consistency PASS/.test(foot) && !/typical/i.test(foot), foot.slice(0, 300));
await p.screenshot({ path: path.join(OUT, '2b-farmland-walk-z22.png') });
// A typed section.
const t = await p.evaluate(async () => { const txt = await window.__trench.cmd('trench w 0.6 d 1.2 cover 0.9 od 160mm'); return { txt, r: window.__trench.check(), s: window.__trench.spec() }; });
check('typed section drawn and checked within 1 cm', t.r.ok && t.s.id === 'typed' && t.s.w === 0.6 && t.s.d === 1.2 && t.s.cover === 0.9 && Math.abs(t.s.od - 0.16) < 1e-12, t.r.text);
await p.evaluate(() => window.SIM.map.fire('moveend')); await p.waitForTimeout(800);
await p.screenshot({ path: path.join(OUT, '4-typed-section.png') });
// A typed section that does not fit is refused, and the drawn one stays.
const bad = await p.evaluate(async () => ({ txt: await window.__trench.cmd('trench w 0.4 d 0.9 cover 0.9 od 160mm'), id: window.__trench.spec().id, w: window.__trench.spec().w }));
check('section that does not fit is refused', /deeper than the trench/.test(bad.txt) && bad.w === 0.6, bad.txt);
// Two circuits (cited 132kv-2).
const two = await p.evaluate(async () => { await window.__trench.cmd('trench 132kv-2'); return window.__trench.check(); });
check('cited 132kv-2 (two circuits) within 1 cm incl. circuit spacing', two.ok && two.rows.some(r => r.what === 'cs'), two.text);
check('catalogue status "typical" is tagged "estimated"', two.rows.find(r => r.what === 'cover').prov === 'estimated' && !two.rows.some(r => /typical/.test(r.prov)), two.rows.map(r => r.what + ':' + r.prov).join(' '));
await p.evaluate(() => window.SIM.map.fire('moveend')); await p.waitForTimeout(800);
await p.screenshot({ path: path.join(OUT, '5-two-circuits.png') });
// X-ray off: the trench is depth-tested like the ground (buried), and the zoom limit is given back.
await p.evaluate(() => window.__trench.cmd('trench go')); await p.waitForTimeout(3000);
await p.screenshot({ path: path.join(OUT, '6-two-circuits-xray-walk.png') });
const off = await p.evaluate(async () => { await window.__trench.cmd('xray off'); await new Promise(r => setTimeout(r, 2500)); return window.SIM.map.getMaxZoom(); });
check('xray off gives the zoom limit back', off === 20, off);
await p.screenshot({ path: path.join(OUT, '7-xray-off.png') });
// Negative control: move one floor vertex of the first rib 2 cm outwards in the GPU buffer; the check must fail.
const neg = await p.evaluate(() => {
const PF = window.__pf.PF, blk = window.__trench.blocks()[0].groups.wall, B0 = window.__trench.blocks()[0], r0 = window.__trench.measureRib(0);
const d = 0.02 * PF.meterInMercator(B0.anchor.lat), saved = blk.buf.slice();
// every buffer vertex at the first rib's far floor corner is moved 2 cm outwards, across the trench
const corner = r0.corners[1], c0 = r0.corners[0], ux = (corner.x - c0.x) / r0.width, uy = (corner.y - c0.y) / r0.width, idx = [];
for (let v = 0; v < blk.lines.length * 2; v++) { const o = PF.toMercator(B0.anchor.lat, B0.anchor.lon, 0), q = PF.mapToWire(B0.anchor, o.x + blk.buf[3 * v], o.y + blk.buf[3 * v + 1], blk.buf[3 * v + 2]);
if (Math.abs(q.x - corner.x) < 1e-4 && Math.abs(q.y - corner.y) < 1e-4 && Math.abs(q.z - corner.z) < 1e-4) idx.push(v); }
for (const v of idx) { blk.buf[3 * v] += ux * d; blk.buf[3 * v + 1] -= uy * d; } // Mercator y grows southwards
const bad = window.__trench.check(); blk.buf.set(saved); const good = window.__trench.check();
return { moved: idx.length, badOk: bad.ok, badWidth: bad.rows.find(r => r.what === 'width').worst_err_m, goodOk: good.ok, width: r0.width };
});
check('negative control: a 2 cm error is caught', neg.moved > 0 && !neg.badOk && neg.badWidth > 0.015 && neg.goodOk, JSON.stringify(neg));
check('no page errors', errs.length === 0, errs.join(' | ') || 'none');
await b.close(); server.close();
fs.writeFileSync(path.join(OUT, 'results.json'), JSON.stringify(results, null, 1));
for (const r of results) console.log(`${r.ok ? 'PASS' : 'FAIL'} ${r.name} -- ${r.evidence}`);
const failed = results.filter(r => !r.ok).length; console.log(`\n${results.length - failed} passed, ${failed} failed`);
process.exit(failed ? 1 : 0);
})().catch(e => { console.error(e); server.close(); process.exit(2); });Cable Cases
A Python module in the bench folder of Faraday that works with cables, using IEC 60228.
electricalfaraday / bench/cable_cases.py · lines 1–71 of 71 · Entry point · pattern registry (shared by 8 files)
- What it does
- It calculates cables. Defines t_withstand, t_run, t_selfcheck, registry. Uses libraries json, math.
- 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.
- Downstream impact
- Used directly by 1 file: Tests (faraday). Reached from 1 other entry point, including One (faraday).
- What it achieves
- It is built from the t withstand helper (`t_withstand`), the t run helper (`t_run`) and the t selfcheck helper (`t_selfcheck`). CABLE CHECK: the four questions every cable sizing study asks, as cases that can fail. Its code works with 17.39 kA.
- Why it matters
- Checked by Tests.
- Application
- faraday · bench · Python module
- Uses
- json, math
- Used by
- imported by Tests (import)
- Produces
- t_withstand, t_run, t_selfcheck, registry
- Defines here
- t_withstand, t_run, t_selfcheck, registry
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- faraday@e439b450f37a8c124fa4a0cb38159ae0dc337062 bench/cable_cases.py:1-71 · blob e0f652a7f3dc06e8ebc3e544175d30a567bbf015 · 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: unknown
#!/usr/bin/env python3
"""bench/cable_cases.py - CABLE CHECK: the four questions every cable sizing study asks, as cases that can fail.
1 sustained current does the cable carry the load current after derating for how it is installed
2 voltage drop is the drop along the run inside the allowed share
3 fault withstand does the conductor survive the fault current for the clearing time (the adiabatic rule)
4 thermal flag is the case close enough to a limit that a buried cable thermal study should be commissioned
GENERIC cases only: no project, no maker, no price. Conductor resistance at 20 C is quoted from memory of the standard for class 2 sizes
(to be keyed against the estate's own conductor resistances table before anyone relies on it)
(IEC 60228, table for stranded conductors); the adiabatic constant k is the published one for the metal and insulation
(aluminium with XLPE 94, copper with XLPE 143; one second rule I = k x S). Current ratings and derating factors are CANDIDATES,
round typical figures, to be overwritten by the owner's own datasheet. The consulting engineer's study is the authority; this
finds which study to commission.
"""
import json
import math
R20 = {'al': {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},
'cu': {50: 0.387, 70: 0.268, 95: 0.193, 120: 0.153, 150: 0.124, 185: 0.0991, 240: 0.0754, 300: 0.0601, 400: 0.0470, 500: 0.0366, 630: 0.0283}}
K = {'al': 94.0, 'cu': 143.0}
ALPHA = {'al': 0.00403, 'cu': 0.00393}
RATING_GROUND = {'al': {50: 150, 70: 185, 95: 220, 120: 250, 150: 280, 185: 320, 240: 370, 300: 420, 400: 480, 500: 545, 630: 615}} # CANDIDATE, amps
RATING_GROUND['cu'] = {s: round(a * 1.28) for s, a in RATING_GROUND['al'].items()} # CANDIDATE ratio
def t_withstand(metal, size, seconds, fault_ka):
limit = K[metal] * size / math.sqrt(seconds) / 1000
ok = fault_ka <= limit
return dict(question='Does a %d mm2 %s conductor with XLPE survive %.1f kA for %.1f s?' % (size, 'aluminium' if metal == 'al' else 'copper', fault_ka, seconds),
sentence='Cable check: fault withstand, %d mm2 %s, %.1f kA for %.1f s' % (size, metal, fault_ka, seconds),
command='fire cable-withstand ' + json.dumps(dict(metal=metal, size_mm2=size, seconds=seconds, fault_ka=fault_ka), sort_keys=True),
did='adiabatic rule: the most the conductor can take is k x area / square root of time, k = %g' % K[metal],
numbers=dict(withstand_ka=round(limit, 2), fault_ka=fault_ka, margin_pct=round((limit / fault_ka - 1) * 100, 1)),
observed='withstands %.2f kA; asked for %.1f kA: %s' % (limit, fault_ka, 'survives' if ok else 'DOES NOT SURVIVE: a larger conductor or faster protection'),
assumed='k is the published constant for the metal with XLPE (90 C to 250 C); the fault current and time are the case', result='CONFIRMED')
def t_run(metal, size, amps, metres, kv, derate):
r_hot = R20[metal][size] * (1 + ALPHA[metal] * (90 - 20)); x = 0.08
vd = math.sqrt(3) * amps * (r_hot * 0.95 + x * math.sqrt(1 - 0.95 ** 2)) * metres / 1000; pct = vd / (kv * 1000) * 100
cap = RATING_GROUND[metal][size] * derate; use = amps / cap * 100
flags = []
if use > 100: flags.append('over its derated rating')
elif use > 85: flags.append('within 15 per cent of its derated rating: commission a buried cable thermal study')
if pct > 1.5: flags.append('voltage drop %.2f%% is over 1.5%%' % pct)
return dict(question='Does a %d mm2 %s three core run carry %d A over %d m at %g kV, derated to %d%%?' % (size, metal, amps, metres, kv, round(derate * 100)),
sentence='Cable check: %d A over %d m on %d mm2 %s at %g kV' % (amps, metres, size, metal, kv),
command='fire cable-run ' + json.dumps(dict(metal=metal, size_mm2=size, amps=amps, metres=metres, kv=kv, derate=derate), sort_keys=True),
did='resistance at 20 C from the standard table, raised to 90 C; drop = root three x amps x (r cos + x sin) x length; rating x derating',
numbers=dict(volt_drop_pct=round(pct, 3), loading_pct=round(use, 1), loss_kw=round(3 * amps ** 2 * r_hot * metres / 1000 / 1000, 2)),
observed=('drop %.2f%%, loaded to %.0f%% of its derated rating; ' % (pct, use)) + ('; '.join(flags) if flags else 'inside both limits'),
assumed='ratings and derating are CANDIDATE round figures; reactance 0.08 ohm/km assumed; power factor 0.95', result='CONFIRMED')
def t_selfcheck():
"""The one case with a known answer: 185 mm2 aluminium for one second is 94 x 185 = 17.39 kA, the figure makers publish."""
got = K['al'] * 185 / 1000
return dict(question='Does the adiabatic rule give the 17.39 kA that is published for 185 mm2 aluminium with XLPE for one second?', sentence='Cable check: the known answer',
command='fire cable-withstand {"fault_ka":17.39,"metal":"al","seconds":1.0,"size_mm2":185}', did='94 x 185 / 1000', numbers=dict(withstand_ka=round(got, 2)),
observed='%.2f kA' % got, assumed='none', result='CONFIRMED' if abs(got - 17.39) < 0.005 else 'REFUTED')
def registry():
R = [('CABLE CHECK', 'the known answer', (t_selfcheck, ()))]
for metal in ('al', 'cu'):
for size in (95, 185, 300, 630):
for seconds in (0.2, 1.0, 3.0):
for ka in (8.0, 16.0, 25.0): R.append(('CABLE CHECK', 'withstand %s %d %.1fs %.0fkA' % (metal, size, seconds, ka), (t_withstand, (metal, size, seconds, ka))))
for metal in ('al', 'cu'):
for size in (95, 185, 300, 630):
for amps in (150, 300, 450):
for metres in (200, 800, 2500):
for kv, derate in ((11.0, 0.8), (33.0, 0.7)): R.append(('CABLE CHECK', 'run %s %d %dA %dm %gkV' % (metal, size, amps, metres, kv), (t_run, (metal, size, amps, metres, kv, derate))))
return RData Core
A JavaScript file in the cable geometry folder of GlobalGrid2050 covering 11kV, 33kV, cables and 110kV, using BS 7870-4 and IEC 60840. Served with the page at https://globalgrid2050.com/cable_geometry/.
Set aside from the main view: 93% of its lines are the same as testcode/202609060432/cable/data-core.js (globalgrid2050), which stays. (near-copy-of, proposed by families.py). 93% of lines shared with Data Core; read that one first. All set-aside files, with reasons. Nothing was deleted.
Evidence
- line-jaccard 0.9333 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 testcode/202609060432/cable/data-core.js:1-308 e3151c1ef34d042427bf6bdeec006bdefd2df478
- sha256 96355cb279ebfdde8298296fa9d1fa8a1496b4573b3add5ca1eb17e6befc3c78
- target sha256 729a68a77264730d17674ce3f2aa69132a2417d98313de823202f53b8e6e0197
- group of 2 (identity.json near-copy edges >= 0.9)
- canonical rule: reachable, newest stamp, core repo, most lines
otherglobalgrid2050 / cable_geometry/data-core.js · lines 1–316 of 316 · Entry point
- 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: 11kV, 33kV, cables, 110kV, 1kV.
- Inputs & outputs
- Voltage levels named: 110kV, 33kV, 11kV, 1kV.
- Downstream impact
- Used directly by 1 file: GlobalGrid2050 — Cable Geometry Page (globalgrid2050, https://globalgrid2050.com/cable_geometry/). Reached from 95 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/cable_geometry/.
- What it achieves
- Core reference data: burial depths, conductor labels, voltage class definitions, CSA ranges, dropdown groups, and formation library. Its code works with 11 kV, 33 kV and 1 kV.
- Why it matters
- Loaded by the Cable Geometry page at https://globalgrid2050.com/cable_geometry/.
- Application
- globalgrid2050 · cable_geometry · script
- Uses
- none found
- Used by
- loaded by GlobalGrid2050 — Cable Geometry Page (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 cable_geometry/data-core.js:1-316 · blob fac3edd425d947f7db732f5325bb78e7330b1cf2 · 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
// =============================================================
// data-core.js
// Core reference data: burial depths, conductor labels,
// voltage class definitions, CSA ranges, dropdown groups,
// and formation library.
// =============================================================
const DEFAULT_BURIAL_DEPTHS = { lv: 900, mv: 900, ehv: 900, dc: 900 };
// Removed enforced minimums — system will not block lower or higher values
const MIN_BURIAL_DEPTHS = null;
const CONDUCTOR_SHAPE_LABELS = {
circular_stranded: “Stranded circular conductor”,
sector_stranded: “Stranded sector conductor”,
compacted_round: “Compacted round conductor”,
solid_round: “Solid round conductor”,
flexible_round: “Flexible round conductor”
};
// =============================================================
// VOLTAGE CLASSES
// =============================================================
const VOLTAGE_CLASSES = {
```
// =========================================================
// LV
// =========================================================
"lv_cu_sc": {
label: "0.6/1 kV Cu XLPE single core",
display_short: "0.6/1 kV Cu 1c",
service_family: "lv",
cores: ["single"],
conductor_material: "Cu",
conductor_shape: "compacted_round"
},
"lv_cu_3c": {
label: "0.6/1 kV Cu XLPE 3 core",
display_short: "0.6/1 kV Cu 3c",
service_family: "lv",
cores: ["three"],
conductor_material: "Cu",
conductor_shape: "sector_stranded",
sectorial: true
},
// =========================================================
// BRITISH MV
// =========================================================
"uk_11kv_sc": {
label: "6.35/11 kV single core XLPE",
display_short: "11 kV 1c",
service_family: "mv",
cores: ["single"],
conductor_material: "Al",
conductor_shape: "compacted_round",
british_system_voltage: "6.35/11 kV",
standard_basis: "BS 7870-4.10"
},
"uk_11kv_3c": {
label: "6.35/11 kV 3 core XLPE",
display_short: "11 kV 3c",
service_family: "mv",
cores: ["three"],
conductor_material: "Cu",
conductor_shape: "sector_stranded",
british_system_voltage: "6.35/11 kV",
standard_basis: "BS 7870-4.10",
sectorial: true
},
"uk_33kv_sc": {
label: "19/33 kV single core XLPE",
display_short: "33 kV 1c",
service_family: "mv",
cores: ["single"],
conductor_material: "Al",
conductor_shape: "compacted_round",
british_system_voltage: "19/33 kV"
},
"uk_33kv_3c": {
label: "19/33 kV 3 core XLPE",
display_short: "33 kV 3c",
service_family: "mv",
cores: ["three"],
conductor_material: "Cu",
conductor_shape: "sector_stranded",
british_system_voltage: "19/33 kV",
sectorial: true
},
// =========================================================
// IEC HV — TENNET ALIGNED
// =========================================================
"iec_110kv_sc": {
label: "64/110 kV single core XLPE (IEC 60840 system)",
display_short: "110 kV 1c IEC",
service_family: "ehv",
cores: ["single"],
conductor_material: "Al",
conductor_shape: "compacted_round",
system_type: "IEC 60840",
grid_reference: "TenneT typical specification",
locked_csa: 630,
metallic_screen: 95
},
// =========================================================
// DC — SOLAR PV STRING
// Flexible tinned Cu, installed in air, tray or conduit
// =========================================================
"pv_string": {
label: "PV string cable flexible Cu (EN 50618 / IEC 62930)",
display_short: "PV string",
service_family: "dc",
cores: ["single"],
conductor_material: "Cu",
conductor_shape: "flexible_round",
system_type: "EN 50618 / IEC 62930",
dc_type: "solar_string"
},
// =========================================================
// DC — FLEXIBLE HV AC RATED (inverter / high-flex use)
// =========================================================
"flex_hv_ac": {
label: "Flexible cable — HV AC rated, single core",
display_short: "Flex HV AC",
service_family: "dc",
cores: ["single"],
conductor_material: "Cu",
conductor_shape: "flexible_round",
dc_type: "flexible_ac_rated"
},
"flex_hv_dc": {
label: "Flexible cable — HV DC rated, single core",
display_short: "Flex HV DC",
service_family: "dc",
cores: ["single"],
conductor_material: "Cu",
conductor_shape: "flexible_round",
dc_type: "flexible_dc_rated"
},
// =========================================================
// DC — ALUMINIUM ARMOURED BURIED (ATA — Al conductor, Al armour)
// Main DC cables: BESS, inverter burial, moisture-blocked
// =========================================================
"al_ata_ac": {
label: "Al armoured buried cable — AC rated (Al/XLPE/SWA/PE)",
display_short: "Al ATA AC",
service_family: "dc",
cores: ["single"],
conductor_material: "Al",
conductor_shape: "compacted_round",
system_type: "Buried moisture-blocked AC rated",
dc_type: "buried_armoured_ac"
},
"al_ata_dc": {
label: "Al armoured buried cable — DC rated (Al/XLPE/SWA/PE)",
display_short: "Al ATA DC",
service_family: "dc",
cores: ["single"],
conductor_material: "Al",
conductor_shape: "compacted_round",
system_type: "Buried moisture-blocked DC rated",
dc_type: "buried_armoured_dc"
}
```
};
// =============================================================
// CSA RANGES BY VOLTAGE KEY
// =============================================================
const CSA_BY_VOLTAGE_KEY = {
```
"lv_cu_sc": [50, 70, 95, 120, 150, 185, 240, 300],
"lv_cu_3c": [50, 70, 95, 120, 150, 185, 240],
"uk_11kv_sc": [70, 95, 120, 150, 185, 240, 300, 400, 500, 630],
"uk_11kv_3c": [70, 95, 120, 150, 185, 240, 300],
"uk_33kv_sc": [95, 120, 150, 185, 240, 300, 400, 500, 630],
"uk_33kv_3c": [95, 120, 150, 185, 240, 300],
"iec_110kv_sc": [630],
"pv_string": [1.5, 2.5, 4, 6, 10, 16, 25, 35, 50, 70, 95, 120, 150, 185, 240],
"flex_hv_ac": [4, 6, 10, 16, 25, 35, 50, 70, 95, 120, 150, 185],
"flex_hv_dc": [4, 6, 10, 16, 25, 35, 50, 70, 95, 120, 150, 185],
"al_ata_ac": [50, 70, 95, 120, 150, 185, 240, 300, 400, 500, 630],
"al_ata_dc": [50, 70, 95, 120, 150, 185, 240, 300, 400, 500, 630]
```
};
// =============================================================
// VOLTAGE DROPDOWN GROUPS
// =============================================================
const VOLTAGE_DROPDOWN_GROUPS = {
```
lv: [
{
label: "Low voltage 0.6/1 kV",
options: [
{ value: "lv_cu_sc", text: "0.6/1 kV single core Cu XLPE" },
{ value: "lv_cu_3c", text: "0.6/1 kV 3 core Cu XLPE (sector conductors)" }
]
}
],
mv: [
{
label: "British medium voltage",
options: [
{ value: "uk_11kv_sc", text: "6.35/11 kV single core XLPE" },
{ value: "uk_11kv_3c", text: "6.35/11 kV 3 core XLPE (sector conductors)" },
{ value: "uk_33kv_sc", text: "19/33 kV single core XLPE" },
{ value: "uk_33kv_3c", text: "19/33 kV 3 core XLPE (sector conductors)" }
]
}
],
ehv: [
{
label: "IEC high voltage transmission",
options: [
{ value: "iec_110kv_sc", text: "64/110 kV single core XLPE (IEC 60840, TenneT system)" }
]
}
],
dc: [
{
label: "Solar PV string",
options: [
{ value: "pv_string", text: "PV string cable flexible Cu (EN 50618 / IEC 62930)" }
]
},
{
label: "Flexible HV rated",
options: [
{ value: "flex_hv_ac", text: "Flexible single core — HV AC rated" },
{ value: "flex_hv_dc", text: "Flexible single core — HV DC rated" }
]
},
{
label: "Buried armoured DC (Al ATA)",
options: [
{ value: "al_ata_ac", text: "Al armoured buried — AC rated (BESS / inverter)" },
{ value: "al_ata_dc", text: "Al armoured buried — DC rated (BESS / inverter)" }
]
}
]
```
};
// =============================================================
// FORMATION LIBRARY
// Defines which formation options are available per service type.
// Values must match case strings in getGroupGeometry().
// =============================================================
const FORMATION_LIBRARY = {
```
lv: [
{ value: "trefoil_single_row", label: "Trefoil — single core, single row" },
{ value: "flat_single_row", label: "Flat — single core, single row" },
{ value: "stacked_two_high", label: "Stacked two high — single core" },
{ value: "multicore_3c", label: "Multicore 3 core" },
{ value: "multicore_4c", label: "Multicore 4 core" },
{ value: "multicore_5c", label: "Multicore 5 core" }
],
mv: [
{ value: "trefoil_single_row", label: "Trefoil — single core, single row" },
{ value: "flat_single_row", label: "Flat — single core, single row" },
{ value: "stacked_two_high", label: "Stacked two high — single core" },
{ value: "multicore_3c", label: "Multicore 3 core" }
],
ehv: [
{ value: "trefoil_single_row", label: "Trefoil — single core, single row" },
{ value: "flat_single_row", label: "Flat — single core, single row" }
],
dc: [
{ value: "dc_pair_horizontal", label: "DC pair — horizontal" },
{ value: "dc_pair_vertical", label: "DC pair — vertical" },
{ value: "flat_single_row", label: "Flat — single core, single row" },
{ value: "trefoil_single_row", label: "Trefoil — single core, single row" }
]
```
};Data LV
A JavaScript file in the cable geometry folder of GlobalGrid2050 covering cables, using BS 5467 and BS 6724. Served with the page at https://globalgrid2050.com/cable_geometry/.
Set aside from the main view: 100% of its lines are the same as testcode/202609060432/cable/data-lv.js (globalgrid2050), which stays. (near-copy-of, proposed by families.py). 100% of lines shared with Data LV; read that one first. All set-aside files, with reasons. Nothing was deleted.
Evidence
- line-jaccard 1.0 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 testcode/202609060432/cable/data-lv.js:1-37 15b73b7612e565c47ede3acc09f59d7659448eb4
- sha256 8460a2fb462deb9d17c811c6a517d968f2c00e7ca7f8c088ea6f911b131c3f80
- target sha256 b6f352b0320e2b1e8cec468403d6de67d364deeaf63c90d4e5b001be4ae1b691
- group of 2 (identity.json near-copy edges >= 0.9)
- canonical rule: reachable, newest stamp, core repo, most lines
otherglobalgrid2050 / cable_geometry/data-lv.js · lines 1–39 of 39 · Entry point
- 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, 1kV.
- Inputs & outputs
- Voltage levels named: 1kV.
- Downstream impact
- Used directly by 1 file: GlobalGrid2050 — Cable Geometry Page (globalgrid2050, https://globalgrid2050.com/cable_geometry/). Reached from 95 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/cable_geometry/.
- What it achieves
- `OD_LV` — Low Voltage Cable OD and MBR Schedule 0.6/1kV Cu XLPE — single core and 3 core Source: Generic UK LV schedule (BS 5467 / BS 6724 basis). Its code works with 1 kV.
- Why it matters
- Loaded by the Cable Geometry page at https://globalgrid2050.com/cable_geometry/.
- Application
- globalgrid2050 · cable_geometry · script
- Uses
- none found
- Used by
- loaded by GlobalGrid2050 — Cable Geometry Page (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 cable_geometry/data-lv.js:1-39 · blob 62119b937750a448f0a274e8ddb5ea5f437671fd · 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
// =============================================================
// OD_LV — Low Voltage Cable OD and MBR Schedule
// 0.6/1 kV Cu XLPE — single core and 3 core
// Source: Generic UK LV schedule (BS 5467 / BS 6724 basis)
// Fixed installation values only. Verify before design use.
// =============================================================
const OD_LV = {
```
// =========================================================
// 0.6/1 kV Single Core Cu XLPE — compacted round conductor
// Key pattern: sc_cu_lv_{csa}
// MBR basis: 15 x OD (lv_cu_sc mbr_factor)
// =========================================================
"sc_cu_lv_50": { od: 14.5, mbr: 218, src: "Generic UK LV schedule" },
"sc_cu_lv_70": { od: 16.5, mbr: 248, src: "Generic UK LV schedule" },
"sc_cu_lv_95": { od: 18.5, mbr: 278, src: "Generic UK LV schedule" },
"sc_cu_lv_120": { od: 20.5, mbr: 308, src: "Generic UK LV schedule" },
"sc_cu_lv_150": { od: 22.5, mbr: 338, src: "Generic UK LV schedule" },
"sc_cu_lv_185": { od: 25.0, mbr: 375, src: "Generic UK LV schedule" },
"sc_cu_lv_240": { od: 28.0, mbr: 420, src: "Generic UK LV schedule" },
"sc_cu_lv_300": { od: 31.0, mbr: 465, src: "Generic UK LV schedule" },
// =========================================================
// 0.6/1 kV 3 Core Cu XLPE — sector stranded conductor
// Key pattern: 3c_cu_lv_{csa}
// MBR basis: 12 x OD (lv_cu_3c mbr_factor)
// =========================================================
"3c_cu_lv_50": { od: 34.0, mbr: 408, src: "Generic UK LV schedule" },
"3c_cu_lv_70": { od: 38.0, mbr: 456, src: "Generic UK LV schedule" },
"3c_cu_lv_95": { od: 42.5, mbr: 510, src: "Generic UK LV schedule" },
"3c_cu_lv_120": { od: 46.5, mbr: 558, src: "Generic UK LV schedule" },
"3c_cu_lv_150": { od: 50.5, mbr: 606, src: "Generic UK LV schedule" },
"3c_cu_lv_185": { od: 55.5, mbr: 666, src: "Generic UK LV schedule" },
"3c_cu_lv_240": { od: 62.0, mbr: 744, src: "Generic UK LV schedule" }
```
};