In this section
- Bng geodesy · energy-transition-simulator / prototype/mod/engine/bng.mjs lines 1–214
- Bs7671 Checks transform · energy-transition-simulator / prototype/mod/engine/bs7671-checks.mjs lines 1–41
- Cmd Derive transform · energy-transition-simulator / prototype/mod/engine/cmd-derive.mjs lines 1–101
- Cmd Grammar Earth ingest · energy-transition-simulator / prototype/mod/engine/cmd-grammar-earth.mjs lines 1–62
- Cmd Grammar Plant ingest · energy-transition-simulator / prototype/mod/engine/cmd-grammar-plant.mjs lines 1–60
- Cmd Grammar Senses ingest · energy-transition-simulator / prototype/mod/engine/cmd-grammar-senses.mjs lines 1–25
Bng
A JavaScript module in the engine folder of Energy Transition Simulator that converts to cartesian (`toCartesian`), parses grid ref (`parseGridRef`) and calculates planar distances and angles, using Helmert and OSTN15.
Set aside from the main view: 99% of its lines are the same as prototype/world/bng.mjs (energy-transition-simulator), which stays. (near-copy-of, proposed by families.py). 98% of lines shared with Bng; read that one first. All set-aside files, with reasons. Nothing was deleted.
Evidence
- line-jaccard 0.9882 to energy-transition-simulator@a165ce6d56cb22271828874d68d570e8fa5e428a prototype/world/bng.mjs:1-212 b7164628503b1e80df26257dc62ecebfa77a4d34
- sha256 a8b290fabb3c2b2443d1e7a56d709a18d5dab858033c489195713ebf48a9a835
- target sha256 999f8363ee1d9c06b6169c0f59803d9a2ac5e2701becd596e29d74550e06971f
- group of 3 (identity.json near-copy edges >= 0.9)
- canonical rule: reachable, newest stamp, core repo, most lines
geodesyenergy-transition-simulator / prototype/mod/engine/bng.mjs · lines 1–214 of 214 · Not reached from any entry point (candidate for review) · pattern fromCartesian (shared by 3 files)
- What it does
- It calculates its inputs. Defines 14 functions or classes, including invert3, apply, toCartesian, fromCartesian, meridional.
- Why it exists in the grid workflow
- Domain stage experimental (path word 'prototype'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
- Inputs & outputs
- Coordinate systems named: OSGB36 / EPSG:27700 (British National Grid), WGS84 / EPSG:4326.
- Downstream impact
- Used directly by 2 files: Journey (energy-transition-simulator); Place Frame Samples (energy-transition-simulator).
- What it achieves
- It parses grid ref (`parseGridRef`) and is built from the invert3 step (`invert3`) and the apply step (`apply`). `bngToWgs84` mirrors `osgb36_to_wgs84` in GlobalGrid2050 `uk_renewables_pipeline/v9.7/scripts/data/build_v7_2_spine.py` term for term (one deliberate difference: the meridian-arc loop, see `tmInverse`).
- Why it matters
- Imported by Journey and Place Frame Samples.
- Application
- energy-transition-simulator · prototype/mod/engine · JavaScript module
- Uses
- none found
- Used by
- imported by Journey (import), imported by Place Frame Samples (dynamic import)
- Produces
- tmForward, tmInverse, bngToWgs84, wgs84ToBng, parseGridRef, gridRef
- Defines here
- invert3, apply, toCartesian, fromCartesian, meridional, tmForward, tmInverse, offset, bngToWgs84, wgs84ToBng, parseGridRef, pad, gridRef, fmt
- 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 prototype/mod/engine/bng.mjs:1-214 · blob 19629430519cae24fa53bbf2d36abe8935ba892c · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: experimental · users: none · canonical: duplicate_candidate
// COPIED UNCHANGED from the v12 world (web/world/bng.mjs) at v12 commit 3adcee9 (file last changed 04b1c72). Modular star family: public #144675 tmForward.
// Do not edit here: change the source and re-copy. Everything below this header is byte-identical to the source.
// British National Grid <-> WGS84, pure functions, no imports, no DOM.
//
// WHAT THIS IS
// bngToWgs84 mirrors osgb36_to_wgs84() in globalgrid2050
// uk_renewables_pipeline/v9.7/scripts/data/build_v7_2_spine.py term for term (one
// deliberate difference: the meridian-arc loop, see tmInverse):
// Transverse Mercator inverse on Airy 1830 with the OS National Grid constants
// (F0 0.9996012717, true origin 49N 2W, false origin E 400000 N -100000), then a
// 7-parameter Helmert OSGB36 -> WGS84 with heights taken as zero on Airy.
// wgs84ToBng is its exact algebraic inverse: the Helmert matrix inverted (not the
// usual sign-flipped approximation, which is out by about 1 cm) and the WGS84 height
// chosen so the Airy height is zero, then the TM forward series, then one fixed-point
// step against tmInverse (the OS forward and inverse series are truncations and part
// by up to 2 mm 400 km from the central meridian). So a round trip through both
// functions closes to well under a millimetre anywhere on the grid.
//
// HOW ACCURATE IT IS, AND IS NOT
// Closing a round trip proves consistency, not truth. The Helmert transformation is
// accurate to about 3.5 m against the real National Grid (Ordnance Survey, "A guide to
// coordinate systems in Great Britain", section 6.6; the OS says 3-5 m and does not
// recommend it where better is needed). The definitive transformation is OSTN15, a
// grid of offsets not held here. Where a site has a known OSTN15 offset it can be
// passed as { de, dn } in metres: wgs84ToBng adds it to the result and bngToWgs84
// removes it before converting, so the pair stays inverses of each other.
//
// Sources: Ordnance Survey, "A guide to coordinate systems in Great Britain" (v3.6),
// Annex B (Helmert), Annex C (Transverse Mercator), Annex C.1 worked example.
const AIRY_A = 6377563.396, AIRY_B = 6356256.909;
const WGS_A = 6378137.0, WGS_B = 6356752.3141;
const F0 = 0.9996012717;
const LAT0 = 49 * Math.PI / 180, LON0 = -2 * Math.PI / 180;
const E0 = 400000, N0 = -100000;
const AIRY_E2 = 1 - (AIRY_B * AIRY_B) / (AIRY_A * AIRY_A);
const WGS_E2 = 1 - (WGS_B * WGS_B) / (WGS_A * WGS_A);
const N_ = (AIRY_A - AIRY_B) / (AIRY_A + AIRY_B);
const RAD = Math.PI / 180, SEC = RAD / 3600;
// OSGB36 -> WGS84, exactly as the Python: x2 = t + M x1
const T = [446.448, -125.157, 542.060];
const RX = 0.1502 * SEC, RY = 0.2470 * SEC, RZ = 0.8421 * SEC;
const S = 1 - 20.4894e-6;
const M = [[S, -RZ, RY], [RZ, S, -RX], [-RY, RX, S]];
function invert3(m) {
const [[a, b, c], [d, e, f], [g, h, i]] = m;
const A = e * i - f * h, B = -(d * i - f * g), C = d * h - e * g;
const det = a * A + b * B + c * C;
return [
[A / det, -(b * i - c * h) / det, (b * f - c * e) / det],
[B / det, (a * i - c * g) / det, -(a * f - c * d) / det],
[C / det, -(a * h - b * g) / det, (a * e - b * d) / det],
];
}
const MI = invert3(M);
const apply = (m, v) => [
m[0][0] * v[0] + m[0][1] * v[1] + m[0][2] * v[2],
m[1][0] * v[0] + m[1][1] * v[1] + m[1][2] * v[2],
m[2][0] * v[0] + m[2][1] * v[1] + m[2][2] * v[2],
];
function toCartesian(lat, lon, h, a, e2) {
const s = Math.sin(lat), c = Math.cos(lat);
const nu = a / Math.sqrt(1 - e2 * s * s);
return [(nu + h) * c * Math.cos(lon), (nu + h) * c * Math.sin(lon), (nu * (1 - e2) + h) * s];
}
// Cartesian -> geodetic, the same fixed-point iteration as the Python (12 steps max).
function fromCartesian(x, y, z, a, e2) {
const p = Math.hypot(x, y);
let lat = Math.atan2(z, p * (1 - e2));
for (let k = 0; k < 12; k++) {
const nu = a / Math.sqrt(1 - e2 * Math.sin(lat) ** 2);
const next = Math.atan2(z + e2 * nu * Math.sin(lat), p);
const done = Math.abs(next - lat) < 1e-12;
lat = next;
if (done) break;
}
const nu = a / Math.sqrt(1 - e2 * Math.sin(lat) ** 2);
const h = Math.abs(Math.cos(lat)) > 1e-9 ? p / Math.cos(lat) - nu : Math.abs(z) - nu * (1 - e2);
return { lat, lon: Math.atan2(y, x), h };
}
function meridional(lat) {
const n = N_, dl = lat - LAT0, sl = lat + LAT0;
const ma = (1 + n + 5 / 4 * n ** 2 + 5 / 4 * n ** 3) * dl;
const mb = (3 * n + 3 * n ** 2 + 21 / 8 * n ** 3) * Math.sin(dl) * Math.cos(sl);
const mc = (15 / 8 * n ** 2 + 15 / 8 * n ** 3) * Math.sin(2 * dl) * Math.cos(2 * sl);
const md = 35 / 24 * n ** 3 * Math.sin(3 * dl) * Math.cos(3 * sl);
return AIRY_B * F0 * (ma - mb + mc - md);
}
/** OSGB36 latitude/longitude (radians, Airy 1830) -> National Grid { e, n }. OS Annex C. */
export function tmForward(lat, lon) {
const s = Math.sin(lat), c = Math.cos(lat), t = Math.tan(lat);
const nu = AIRY_A * F0 / Math.sqrt(1 - AIRY_E2 * s * s);
const rho = AIRY_A * F0 * (1 - AIRY_E2) / (1 - AIRY_E2 * s * s) ** 1.5;
const eta2 = nu / rho - 1;
const I = meridional(lat) + N0;
const II = nu / 2 * s * c;
const III = nu / 24 * s * c ** 3 * (5 - t ** 2 + 9 * eta2);
const IIIA = nu / 720 * s * c ** 5 * (61 - 58 * t ** 2 + t ** 4);
const IV = nu * c;
const V = nu / 6 * c ** 3 * (nu / rho - t ** 2);
const VI = nu / 120 * c ** 5 * (5 - 18 * t ** 2 + t ** 4 + 14 * eta2 - 58 * t ** 2 * eta2);
const dl = lon - LON0;
return {
e: E0 + IV * dl + V * dl ** 3 + VI * dl ** 5,
n: I + II * dl ** 2 + III * dl ** 4 + IIIA * dl ** 6,
};
}
/** National Grid (e, n) -> OSGB36 { lat, lon } in radians on Airy 1830. Mirrors the Python. */
export function tmInverse(easting, northing) {
let lat = LAT0, m = 0;
// OS Annex C.6 repeats while |N - N0 - M| >= 0.01 mm. The Python tests the signed value,
// so north of about 55N, where a step overshoots, it stops early: 3-11 cm out in Scotland
// and up to 46 m north of N 1,210,000. Here the absolute value, as the OS writes it.
for (let k = 0; k < 100 && Math.abs(northing - N0 - m) >= 0.00001; k++) {
lat += (northing - N0 - m) / (AIRY_A * F0);
m = meridional(lat);
}
const s = Math.sin(lat), c = Math.cos(lat), t = Math.tan(lat);
const nu = AIRY_A * F0 / Math.sqrt(1 - AIRY_E2 * s * s);
const rho = AIRY_A * F0 * (1 - AIRY_E2) / (1 - AIRY_E2 * s * s) ** 1.5;
const eta2 = nu / rho - 1;
const de = easting - E0;
const VII = t / (2 * rho * nu);
const VIII = t / (24 * rho * nu ** 3) * (5 + 3 * t ** 2 + eta2 - 9 * t ** 2 * eta2);
const IX = t / (720 * rho * nu ** 5) * (61 + 90 * t ** 2 + 45 * t ** 4);
const X = 1 / (c * nu);
const XI = 1 / (c * 6 * nu ** 3) * (nu / rho + 2 * t ** 2);
const XII = 1 / (c * 120 * nu ** 5) * (5 + 28 * t ** 2 + 24 * t ** 4);
const XIIA = 1 / (c * 5040 * nu ** 7) * (61 + 662 * t ** 2 + 1320 * t ** 4 + 720 * t ** 6);
return {
lat: lat - VII * de ** 2 + VIII * de ** 4 - IX * de ** 6,
lon: LON0 + X * de - XI * de ** 3 + XII * de ** 5 - XIIA * de ** 7,
};
}
const offset = (o) => ({ de: (o && Number.isFinite(o.de)) ? o.de : 0, dn: (o && Number.isFinite(o.dn)) ? o.dn : 0 });
/** National Grid easting/northing (m) -> WGS84 { lat, lon } in degrees. */
export function bngToWgs84(e, n, ostn) {
const { de, dn } = offset(ostn);
const g = tmInverse(e - de, n - dn);
const p = toCartesian(g.lat, g.lon, 0, AIRY_A, AIRY_E2);
const q = apply(M, p);
const w = fromCartesian(q[0] + T[0], q[1] + T[1], q[2] + T[2], WGS_A, WGS_E2);
return { lat: w.lat / RAD, lon: w.lon / RAD };
}
/** WGS84 { lat, lon } in degrees -> National Grid { e, n } in metres. Exact inverse of bngToWgs84. */
export function wgs84ToBng(lat, lon, ostn) {
const { de, dn } = offset(ostn);
const la = lat * RAD, lo = lon * RAD;
let h = 0, g = null;
// bngToWgs84 puts the point at height zero on Airy; find the WGS84 height that does too.
for (let k = 0; k < 4; k++) {
const w = toCartesian(la, lo, h, WGS_A, WGS_E2);
const p = apply(MI, [w[0] - T[0], w[1] - T[1], w[2] - T[2]]);
g = fromCartesian(p[0], p[1], p[2], AIRY_A, AIRY_E2);
if (Math.abs(g.h) < 1e-6) break;
h -= g.h;
}
const r0 = tmForward(g.lat, g.lon);
let r = r0;
for (let k = 0; k < 3; k++) { // make it the inverse of tmInverse, not just the OS series
const back = tmInverse(r.e, r.n), b = tmForward(back.lat, back.lon);
r = { e: r.e + (r0.e - b.e), n: r.n + (r0.n - b.n) };
}
return { e: r.e + de, n: r.n + dn };
}
// ---- grid references: two letters for the 100 km square, then digits ----
const LETTERS = 'ABCDEFGHJKLMNOPQRSTUVWXYZ'; // 25 letters, no I
/** 'TQ 30 80' / 'TQ3080' / 'tq 3000 8000' -> { e, n } of the square's south-west corner. */
export function parseGridRef(ref) {
const s = String(ref ?? '').toUpperCase().replace(/[\s,]+/g, ' ').trim();
const m = /^([A-HJ-Z])([A-HJ-Z])\s*(\d*)\s*(\d*)$/.exec(s);
if (!m) throw new Error(`not a grid reference: ${ref}`);
const l1 = LETTERS.indexOf(m[1]), l2 = LETTERS.indexOf(m[2]);
const e100 = ((l1 - 2) % 5) * 5 + (l2 % 5);
const n100 = (19 - Math.floor(l1 / 5) * 5) - Math.floor(l2 / 5);
let de = m[3], dn = m[4];
if (!dn) { // run together: split in half
if (de.length % 2) throw new Error(`odd number of digits: ${ref}`);
dn = de.slice(de.length / 2); de = de.slice(0, de.length / 2);
}
if (de.length !== dn.length || de.length > 5) throw new Error(`unbalanced digits: ${ref}`);
const pad = (d) => (d ? Number((d + '00000').slice(0, 5)) : 0);
const e = e100 * 100000 + pad(de), n = n100 * 100000 + pad(dn);
if (e100 < 0 || e100 > 6 || n100 < 0 || n100 > 12) throw new Error(`square outside the grid: ${ref}`);
return { e, n };
}
/** { e, n } -> 'TQ 30 80' with `digits` digits in all (0, 2, 4, ... 10). Truncates, as the OS does. */
export function gridRef(e, n, digits = 10) {
if (!(digits >= 0 && digits <= 10 && digits % 2 === 0)) throw new Error(`digits must be 0..10 and even: ${digits}`);
if (!(e >= 0 && e < 700000 && n >= 0 && n < 1300000)) throw new Error(`outside the grid: ${e}, ${n}`);
const e100 = Math.floor(e / 100000), n100 = Math.floor(n / 100000);
const l1 = (19 - n100) - ((19 - n100) % 5) + Math.floor((e100 + 10) / 5);
const l2 = ((19 - n100) * 5) % 25 + (e100 % 5);
const sq = LETTERS[l1] + LETTERS[l2];
if (digits === 0) return sq;
const k = digits / 2, div = 10 ** (5 - k);
const fmt = (v) => String(Math.floor((v % 100000) / div)).padStart(k, '0');
return `${sq} ${fmt(e)} ${fmt(n)}`;
}Bs7671 Checks
A JavaScript module in the engine folder of Energy Transition Simulator that works with cables, using BS 7671.
Set aside from the main view: 94% of its lines are the same as solar-design-studio/202609271853-site-world/world/bs7671-checks.mjs (globalgrid2050), which stays. (near-copy-of, proposed by families.py). 93% of lines shared with Bs7671 Checks; read that one first. All set-aside files, with reasons. Nothing was deleted.
Evidence
- line-jaccard 0.9394 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-design-studio/202609271853-site-world/world/bs7671-checks.mjs:1-39 14883fb8cb01c646cfbdbc8703e73db195aa9c2c
- sha256 a7b0b522ec44962bbc5ec3a1515d9676afe3d225ff7b32784dba65ae50fdde93
- target sha256 5972d408caa0b02b50953e8e97046ada7333b5f4fc721a7a890a4cf12d5959b0
- group of 3 (identity.json near-copy edges >= 0.9)
- canonical rule: reachable, newest stamp, core repo, most lines
transformenergy-transition-simulator / prototype/mod/engine/bs7671-checks.mjs · lines 1–41 of 41 · Not reached from any entry point (candidate for review) · pattern buriedProtection (shared by 3 files)
- What it does
- It calculates cables. Defines buriedOverload, buriedProtection, disconnection.
- Why it exists in the grid workflow
- Domain stage experimental (path word 'prototype'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow. Domain terms in the code: cables.
- Downstream impact
- Used directly by 1 file: LV DC Sizing (energy-transition-simulator).
- What it achieves
- It is built from the buried overload helper (`buriedOverload`), the buried protection helper (`buriedProtection`) and the disconnection step (`disconnection`). Checks on the LV cable engines from a cross-check against the national wiring rules.
- Why it matters
- Imported by LV DC Sizing.
- Application
- energy-transition-simulator · prototype/mod/engine · JavaScript module
- Uses
- none found
- Used by
- imported by LV DC Sizing (import), mentioned in Standalone (comment link)
- Produces
- SOIL_SENSITIVITY, BURIED, buriedOverload, buriedProtection, DISCONNECT_S, disconnection
- Defines here
- buriedOverload, buriedProtection, disconnection
- 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 prototype/mod/engine/bs7671-checks.mjs:1-41 · blob 3eb79c44e24d3aa4c2b25c482eb860fb832ab020 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: experimental · users: none · canonical: duplicate_candidate
// COPIED UNCHANGED from the v12 world (web/world/bs7671-checks.mjs) at v12 commit 3adcee9 (file last changed 9b1ffad). Modular star family: not known to star-find.
// Do not edit here: change the source and re-copy. Everything below this header is byte-identical to the source.
// bs7671-checks.mjs: checks on the LV cable engines from a cross-check against the national wiring rules. Clauses are
// cited by number only; no table, figure or wording of the rules is held here. Every value below is ours, an input,
// and editable. Illustrative, early design, no warranty: confirm with a qualified engineer.
// ---- overload of buried cables (BS 7671 433.1.203) ----
// The general condition (433.1.1) is kept; for a cable in the ground the check is also made with the soil thermal
// resistivity raised by this factor (our sensitivity margin, not a figure from the rules), because a buried cable's
// rating falls as the ground dries. The verdict at the stated soil and at the raised soil are both reported.
export const SOIL_SENSITIVITY = 1.25;
export const BURIED = new Set(['buried', 'ducts', 'direct', 'duct']);
/** buriedOverload({ In, izAt(soilKmW), soilKmW, factor }) -> { name, ok, value, limit, soilKmW } (value In, limit Iz there). */
export function buriedOverload({ In, izAt, soilKmW, factor = SOIL_SENSITIVITY }) {
const soil = soilKmW * factor, Iz = izAt(soil);
return { name: `buried cable: In <= Iz at soil +${Math.round((factor - 1) * 100)} % (BS 7671 433.1.203)`, ok: In <= Iz + 1e-9,
value: In, limit: Iz, soilKmW: soil };
}
// ---- protection of buried LV and DC cable (BS 7671 522.8.10) ----
/** buriedProtection({ armoured, ducted, kind }) -> a check: a cable in the ground needs an earthed armour or metal sheath,
* or a duct giving like protection. Unarmoured cable laid direct fails. */
export function buriedProtection({ armoured = false, ducted = false, kind = 'LV' } = {}) {
const ok = !!armoured || !!ducted;
return { name: `${kind} cable in the ground: armoured and earthed, or in a duct (BS 7671 522.8.10)`, ok,
value: armoured ? 'armoured' : ducted ? 'ducted' : 'unarmoured, laid direct', limit: 'armour or duct' };
}
// ---- disconnection time by circuit type (BS 7671 411.3.2) ----
// Distribution circuits (411.3.2.3) are allowed longer than small final circuits (411.3.2.2). The times are inputs:
// the distribution time follows 411.3.2.3; the final-circuit time is an input to set from 411.3.2.2 for the circuit.
export const DISCONNECT_S = Object.freeze({ distribution: 5, final: 0.4 });
/** disconnection(p) -> { circuit, permittedS, ia, fastIa }: Ia is the device's current at the permitted time (from its curve,
* as a multiple of In: p.iaMultipleAtPermitted, assumed); fastIa is its instantaneous pick-up (p.tripMultiple). */
export function disconnection(p) {
const circuit = p.circuit === 'final' ? 'final' : 'distribution', permittedS = p.permittedS ?? DISCONNECT_S[circuit];
const mult = circuit === 'final' ? p.tripMultiple : (p.iaMultipleAtPermitted ?? p.tripMultiple);
return { circuit, permittedS, ia: p.inA * mult, fastIa: p.inA * p.tripMultiple };
}Cmd Derive
A JavaScript module in the engine folder of Energy Transition Simulator that works with cables and 33kV.
Set aside from the main view: 97% of its lines are the same as solar-design-studio/202609271740-site-world/world/cmd-derive.mjs (globalgrid2050), which stays. (near-copy-of, proposed by families.py). 97% of lines shared with Cmd Derive; read that one first. All set-aside files, with reasons. Nothing was deleted.
Evidence
- line-jaccard 0.974 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-design-studio/202609271740-site-world/world/cmd-derive.mjs:1-99 8b3cb3dbf647d2f4b7fcf7f94d857d723e21e37b
- sha256 23d423a5908f0bc0e3cda506526a2038337d7886c613f9ff3e8973204f20a168
- target sha256 c727fc45681064162e5a034c5897f23d2a9deb02a8b89702f2ea62f1bba6b49c
- group of 3 (identity.json near-copy edges >= 0.9)
- canonical rule: reachable, newest stamp, core repo, most lines
transformenergy-transition-simulator / prototype/mod/engine/cmd-derive.mjs · lines 1–101 of 101 · Not reached from any entry point (candidate for review) · pattern stringLoops (shared by 3 files)
- What it does
- It calculates cables and 33kV. Defines 12 functions or classes, including noonSun, rowShade, formationOf, cableFor, bendOf.
- Why it exists in the grid workflow
- Domain stage experimental (path word 'prototype'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow. Domain terms in the code: cables, 33kV.
- Inputs & outputs
- Voltage levels named: 33kV.
- Downstream impact
- Used directly by 1 file: Cmd Model (energy-transition-simulator).
- What it achieves
- It is built from the noon sun helper (`noonSun`), the row shade helper (`rowShade`) and the formation of helper (`formationOf`). The quantities a typed command changes, worked out from its inputs. Its code works with 33 kV.
- Why it matters
- Imported by Cmd Model.
- Application
- energy-transition-simulator · prototype/mod/engine · JavaScript module
- Uses
- Module Catalogue (import)
- Used by
- imported by Cmd Model (import), mentioned in Standalone (comment link)
- Produces
- noonSun, rowShade, formationOf, cableFor, bendOf, BED_M, trenchOf, shoelace, LOOP_ASSUMED, stringLoops, coldVoc, soilEffect
- Defines here
- noonSun, rowShade, formationOf, cableFor, bendOf, m, trenchOf, shoelace, stringLoops, coldVoc, cap, soilEffect
- 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 prototype/mod/engine/cmd-derive.mjs:1-101 · blob 93b29bc5b2f42b18d7355fa3b89dc8b4a6e4481f · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: experimental · users: none · canonical: duplicate_candidate
// COPIED UNCHANGED from the v12 world (web/world/cmd-derive.mjs) at v12 commit 3adcee9 (file last changed 8903e78). Modular star family: public #147688 noonSun.
// Do not edit here: change the source and re-copy. Everything below this header is byte-identical to the source.
// cmd-derive.mjs: the quantities a typed command changes, worked out from its inputs. Pure: no DOM.
// sun and shade noon sun height at the solstices for the site latitude; the shadow a row casts on level ground
// cable outside diameter and bend radius from data/cables.json (installation and final multiples of OD)
// trench the cable formation's span and height, the cover left over it, and whether it fits the width
// string loops the area enclosed between the + and - conductors of one string, standard and leapfrog wiring,
// by the closed-path winding area (shoelace), the text engine's method (closed-path-winding-area.v1)
// Illustrative: conductor routes on the table are ASSUMED (named below); nothing here is a design for any site.
import { coldVocOf } from './module-catalogue.mjs';
const DEG = Math.PI / 180, TILT_AXIS = 23.44;
/** Noon sun elevation (degrees) on the winter and summer solstices and the equinox, at latitude latDeg. */
export function noonSun(latDeg) {
return { winter: 90 - latDeg - TILT_AXIS, equinox: 90 - latDeg, summer: Math.min(90, 90 - latDeg + TILT_AXIS) };
}
/** Shadow of a south row on level ground at noon: { shadowM, gapM, shaded } for a table of rise and plan depth. */
export function rowShade({ rise, depth, pitch, elevDeg }) {
const shadowM = elevDeg > 0 ? rise / Math.tan(elevDeg * DEG) : Infinity, gapM = pitch - depth;
return { shadowM, gapM, shaded: shadowM > gapM + 1e-9 };
}
// The formation of three single-core cables of outside diameter od (m): trefoil touching, or flat spaced one OD apart.
export function formationOf(formation, od) {
return formation === 'flat' ? { span: 5 * od, height: od, centres: [[-2 * od, od / 2], [0, od / 2], [2 * od, od / 2]] }
: { span: 2 * od, height: od * (1 + Math.sqrt(3) / 2), centres: [[-od / 2, od / 2], [od / 2, od / 2], [0, od / 2 + od * Math.sqrt(3) / 2]] };
}
/** The cable from the catalogue (data/cables.json) for a size and conductor, 33 kV single core. */
export function cableFor(catalogue, size, metal = 'al') {
const list = catalogue?.cables || [];
const want = metal === 'cu' ? new RegExp(`^33kv-1c-cu-xlpe-${size}(-|$)`) : new RegExp(`^33kv-1c-al-xlpe-${size}$`);
const c = list.find(x => want.test(x.id));
return c ? { id: c.id, od: c.od_mm / 1000, odMm: c.od_mm, armoured: /armoured/.test(c.id), status: c.status || 'catalogue' } : null;
}
/** Bend radius at the cable's inner edge: installation and final multiples of OD from the catalogue's rules. */
export function bendOf(catalogue, cable) {
if (!cable) return null;
const rules = (catalogue?.rules || []).filter(x => x.voltage_kv === 33 && x.construction === (cable.armoured ? 'single_core_armoured' : 'single_core_unarmoured'));
const m = when => rules.find(x => x.when === when)?.multiple_of_od ?? null;
const inst = m('installation'), fin = m('final');
return { installM: inst ? inst * cable.od : null, finalM: fin ? fin * cable.od : null, installX: inst, finalX: fin,
source: rules.find(x => x.when === 'installation')?.source || 'no rule in the catalogue' };
}
export const BED_M = 0.075, SIDE_M = 0.1, AGRI_COVER_M = 0.91; // bedding under the cables; side clearance each side (assumed)
/** Trench with its cables: the cover left to the top cable, and whether the formation fits the width. */
export function trenchOf({ depth, width, formation, od }) {
const f = formationOf(formation, od), cover = depth - BED_M - f.height;
return { ...f, cover, fits: width >= f.span + 2 * SIDE_M - 1e-9, needWidth: f.span + 2 * SIDE_M, agriShort: AGRI_COVER_M - cover };
}
/** Signed area of a closed polyline (shoelace). */
export function shoelace(pts) {
let a = 0;
for (let i = 0; i < pts.length; i++) { const [x0, y0] = pts[i], [x1, y1] = pts[(i + 1) % pts.length]; a += x0 * y1 - x1 * y0; }
return a / 2;
}
// ASSUMED routes on one tier of a portrait table (u along the row, w up the module from its lower edge):
// junction boxes 0.15 of the module length below the top edge; module leads either side of the box 0.06 m apart;
// the standard string's return lead clipped to the lower purlin, 0.25 of the module length up.
export const LOOP_ASSUMED = Object.freeze({ jboxFromTop: 0.15, leadHalfGapM: 0.06, purlinAt: 0.25 });
/** The loop between + and - of one string: { standard, leapfrog } each { poly, area } in m and m². */
export function stringLoops({ mps, moduleShortM = 1.134, moduleLongM = 2.384, moduleGapM = 0.02 }, a = LOOP_ASSUMED) {
const pitch = moduleShortM + moduleGapM, x = i => (i + 0.5) * pitch, L = mps * pitch - moduleGapM;
const yj = moduleLongM * (1 - a.jboxFromTop), yr = moduleLongM * a.purlinAt, d = a.leadHalfGapM;
// Standard: out along the boxes from the first module to the last, home along the purlin.
const standard = [[0, yj], ...Array.from({ length: mps }, (_, i) => [x(i), yj]), [L, yj], [L, yr], [0, yr]];
// Leapfrog: out on every other module, back on the ones skipped; both ends at the start of the row.
const odd = Array.from({ length: mps }, (_, i) => i).filter(i => i % 2 === 0), even = Array.from({ length: mps }, (_, i) => i).filter(i => i % 2);
const leapfrog = [[0, yj + d], ...odd.map(i => [x(i), yj + d]), [L, yj + d], [L, yj - d], ...even.reverse().map(i => [x(i), yj - d]), [0, yj - d]];
return { standard: { poly: standard, area: Math.abs(shoelace(standard)) }, leapfrog: { poly: leapfrog, area: Math.abs(shoelace(leapfrog)) }, lengthM: L };
}
/** Sizing cold open-circuit voltage of one module (the stricter of the coldest cell and Voc x 1.15) and of a string of n (V). */
export function coldVoc({ voc, coeff = -0.0025, minC = -10 }, n) {
const v = coldVocOf({ voc, coeffPctPerK: coeff * 100, tC: minC }).v;
return { module: v, string: v * n, most: Math.floor(1500 / v) };
}
const cap = s => String(s || '').toLowerCase().replace(/\b\w/g, c => c.toUpperCase());
/** The ground at a point (layers/ground.mjs at()) in words, and what it means for the trench. */
export function soilEffect(here) {
const head = 'Soil type from BGS 1:625k';
if (!here || (here.superficial === null && here.bedrock === null)) return `${head}: not in this site's ground file; trench in normal ground assumed.`;
const sup = here.superficial || [], rock = (here.bedrock || [])[0];
const soft = sup.find(s => /alluvi|peat|tidal|lacustrine|marine|clay|silt/i.test(`${s.name} ${s.lithology || ''}`));
const rockWords = rock ? `bedrock ${cap(rock.name)} (${String(rock.lithology || 'lithology not given').toLowerCase()})` : 'no bedrock mapped here';
if (soft) return `${head}: ${cap(soft.name)} over ${rockWords} → trench option alluvium / soft wet ground (support or batter, dewatering).`;
if (sup.length) return `${head}: ${cap(sup[0].name)} over ${rockWords} → trench in normal ground.`;
const hard = rock && /limestone|sandstone|granite|basalt|dolerite|chalk/i.test(rock.lithology || '');
return `${head}: no superficial deposit mapped (${here.superficial === null ? 'not imported' : 'queried, none'}); ${rockWords} → trench in normal ground`
+ `${hard ? '; rock may lie near the surface, allow for breaking out' : ''}.`;
}Cmd Grammar Earth
A JavaScript module in the engine folder of Energy Transition Simulator covering cables.
Set aside from the main view: 96% of its lines are the same as solar-design-studio/202609271740-site-world/world/cmd-grammar-earth.mjs (globalgrid2050), which stays. (near-copy-of, proposed by families.py). 96% of lines shared with Cmd Grammar Earth; read that one first. All set-aside files, with reasons. Nothing was deleted.
Evidence
- line-jaccard 0.96 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-design-studio/202609271740-site-world/world/cmd-grammar-earth.mjs:1-60 0c8ba71512223c7f446770a792604fcd85e0f082
- sha256 1dfe4985699353174cf166c64ee45a0e4288212fe0c2948c61ed369b43b79ae6
- target sha256 d941ab42143e7c08bbffd88d8e66dda288d836bc1dbbf29e07ab60258953ee76
- group of 3 (identity.json near-copy edges >= 0.9)
- canonical rule: reachable, newest stamp, core repo, most lines
ingestenergy-transition-simulator / prototype/mod/engine/cmd-grammar-earth.mjs · lines 1–62 of 62 · Not reached from any entry point (candidate for review) · pattern isThermalSoil (shared by 3 files)
- What it does
- It lists and searches cables. Defines isNum, isThermalSoil, parseEarth, has, chk.
- Why it exists in the grid workflow
- Domain stage experimental (path word 'prototype'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow. Domain terms in the code: cables.
- Downstream impact
- Used directly by 1 file: Cmd Grammar (energy-transition-simulator).
- What it achieves
- It parses earth (`parseEarth`) and is built from the is num helper (`isNum`) and the is thermal soil helper (`isThermalSoil`). The earthing words of the command line (earthing, earth, soil rho, bonding), split out of `cmd-grammar.mjs` to keep each cartridge under 400 lines.
- Why it matters
- Imported by Cmd Grammar.
- Application
- energy-transition-simulator · prototype/mod/engine · JavaScript module
- Uses
- none found
- Used by
- imported by Cmd Grammar (import)
- Produces
- EARTH_KEYS, EARTH_COMMANDS, EARTH_ALIASES, isThermalSoil, parseEarth
- Defines here
- isNum, isThermalSoil, parseEarth, has, chk
- 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 prototype/mod/engine/cmd-grammar-earth.mjs:1-62 · blob 1fe6e627f69ff0de9f2e01632eb7a94783964c32 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: experimental · users: none · canonical: duplicate_candidate
// COPIED UNCHANGED from the v12 world (web/world/cmd-grammar-earth.mjs) at v12 commit 3adcee9 (file last changed 8903e78). Modular star family: public #148228 parseEarth.
// Do not edit here: change the source and re-copy. Everything below this header is byte-identical to the source.
// cmd-grammar-earth.mjs: the earthing words of the command line (earthing, earth, soil rho, bonding), split out of
// cmd-grammar.mjs to keep each cartridge under 400 lines. Pure: parse() hands each verb here with its words.
// Earthing settings (typed, checked like KEYS; held by the earthing cartridge, earth-mount.mjs).
export const EARTH_KEYS = Object.freeze({ mesh: { label: 'earth grid mesh spacing', unit: 'm', min: 2, max: 20 },
ring: { label: 'earth ring depth', unit: 'm', min: 0.3, max: 2 }, rods: { label: 'rods per station', unit: 'rods', min: 0, max: 40, int: true },
rodLength: { label: 'rod length', unit: 'm', min: 1.2, max: 12 }, target: { label: 'earth resistance target', unit: 'Ω', min: 0.1, max: 50 },
split: { label: 'split factor', unit: '', min: 0.05, max: 1 }, rho: { label: 'soil resistivity', unit: 'Ω·m', min: 1, max: 10000 } });
// The earthing verbs for help and search, and their plain words (longest first; the grammar applies them to whole words).
export const EARTH_COMMANDS = Object.freeze([
{ verb: 'earthing', usage: 'earthing show · earthing hide · earthing dc floating · earthing dc earthed',
words: 'earth electrode rod ring grid mesh bonding touch step epr resistance layer' },
{ verb: 'earth', usage: 'earth grid 5m · earth ring 0.6m · earth rods 4 2.4m · earth target 2 · earth split 0.5',
words: 'earthing electrode rod ring grid mesh spacing depth target resistance split factor substation station' },
{ verb: 'bonding', usage: 'bonding single-point · bonding both-ends · bonding cross · bonding auto', words: 'cable screen sheath svl link box ecc earthing' },
]);
export const EARTH_ALIASES = Object.freeze([
['soil thermal resistivity', 'soil'], ['thermal resistivity', 'soil'], ['soil resistivity', 'soil rho'],
['earth grid', 'earth mesh'], ['earthing grid', 'earth mesh'], ['cross bonded', 'cross'], ['cross-bonded', 'cross'],
['cross bonding', 'cross'], ['single point', 'single-point'], ['both ends', 'both-ends'], ['ohm m', 'ohmm'], ['ohm-m', 'ohmm'], ['ohm.m', 'ohmm'],
['ohms', 'ohm'], ['resistivity', 'rho'], ['solid', 'both-ends'], ['bond', 'bonding']
]);
const isNum = t => t && typeof t === 'object' && Number.isFinite(t.n);
/** soil N alone (or in K.m/W) is the cable rating's thermal resistivity, not an earthing word. */
export const isThermalSoil = rest => !rest.includes('rho') && !rest.includes('survey') && !rest.some(x => isNum(x) && /^ohm/.test(x.unit || ''));
/**
* parseEarth(v, rest, bad, eg) -> { act, arg } or null (refused; the reason pushed on bad).
* v: earthing | earth | soil | bonding; rest: the words and numbers after it; eg(what): an example for the verb.
*/
export function parseEarth(v, rest, bad, eg) {
const has = w => rest.includes(w);
if (v === 'earthing' && has('dc')) { // the DC array's earthing: floating (the default) or one pole earthed
const d = ['floating', 'earthed'].find(has);
if (!d) { bad.push('earthing dc takes floating or earthed'); return null; }
return { act: 'earthing', arg: { what: 'dc', value: d } };
}
if (v === 'earthing') return { act: 'earthing', arg: { what: has('hide') ? 'hide' : 'show' } };
if (v === 'bonding') {
const b = ['single-point', 'both-ends', 'cross', 'auto'].find(has);
if (!b) { bad.push('bonding takes single-point, both-ends, cross or auto'); return null; }
return { act: 'earthing', arg: { what: 'bonding', value: b } };
}
const what = v === 'soil' ? (has('survey') ? 'survey' : 'rho') : ['mesh', 'ring', 'rods', 'target', 'split'].find(has);
if (!what) { bad.push('earth takes grid, ring, rods, target or split, e.g. earth grid 5m'); return null; }
const ns = rest.filter(isNum);
const chk = (k, x) => { const K = EARTH_KEYS[k], n = x.unit === 'cm' ? x.n / 100 : x.unit === 'mm' ? x.n / 1000 : x.n;
const ok = n >= K.min && n <= K.max && (!K.int || Math.round(n) === n);
if (!ok) bad.push(`${K.label} must be ${K.int ? 'a whole number' : 'a number'} from ${K.min} to ${K.max}${K.unit ? ' ' + K.unit : ''}; you typed ${x.n}${x.unit}`);
return n; };
const out = { act: 'earthing', arg: { what: what === 'mesh' ? 'grid' : what, value: null, value2: null } };
if (what === 'survey') return out;
if (!ns.length && what !== 'mesh') { bad.push(`${v} ${what} needs a number, e.g. ${eg(what)}`); return null; }
if (ns[0]) out.arg.value = chk(what, ns[0]);
if (what === 'rods' && ns[1]) out.arg.value2 = chk('rodLength', ns[1]);
return out;
}Cmd Grammar Plant
A JavaScript module in the engine folder of Energy Transition Simulator. It parses plant (`parsePlant`) and is built from the has step (`has`).
Set aside from the main view: 96% of its lines are the same as solar-design-studio/202609271853-site-world/world/cmd-grammar-plant.mjs (globalgrid2050), which stays. (near-copy-of, proposed by families.py). 96% of lines shared with Cmd Grammar Plant; read that one first. All set-aside files, with reasons. Nothing was deleted.
Evidence
- line-jaccard 0.9623 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-design-studio/202609271853-site-world/world/cmd-grammar-plant.mjs:1-58 c2cdf8ecb478fd310c5f418bf1a7515328b9ff30
- sha256 17bae6e2c2b16812f574f9553ec1eed0b7db112bd28e7cc6b98e01430cd67959
- target sha256 236f3f02a7feb5a1599e60a769f3cdadd2ee7adcb264f46be7f44db69ceeef3f
- group of 3 (identity.json near-copy edges >= 0.9)
- canonical rule: reachable, newest stamp, core repo, most lines
ingestenergy-transition-simulator / prototype/mod/engine/cmd-grammar-plant.mjs · lines 1–60 of 60 · Not reached from any entry point (candidate for review) · pattern parsePlant (shared by 3 files)
- What it does
- It lists and searches its content. Defines parsePlant, has, at.
- Why it exists in the grid workflow
- Domain stage experimental (path word 'prototype'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
- Downstream impact
- Used directly by 1 file: Cmd Grammar (energy-transition-simulator).
- What it achieves
- The typed words for the plant's inverter class, its packing and the study presets. Its code works with 2500 kVA, 300 kVA and 400 kVA.
- Why it matters
- Imported by Cmd Grammar.
- Application
- energy-transition-simulator · prototype/mod/engine · JavaScript module
- Uses
- Structure Presets (import)
- Used by
- imported by Cmd Grammar (import)
- Produces
- PLANT_KEYS, PLANT_COMMANDS, PLANT_VOCAB, parsePlant
- Defines here
- parsePlant, has, at
- 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 prototype/mod/engine/cmd-grammar-plant.mjs:1-60 · blob c46366e8ac2f91c9072c8438be5c28f1ddac0fc9 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: experimental · users: none · canonical: duplicate_candidate
// COPIED UNCHANGED from the v12 world (web/world/cmd-grammar-plant.mjs) at v12 commit 3adcee9 (file last changed a83209f). Modular star family: not known to star-find.
// Do not edit here: change the source and re-copy. Everything below this header is byte-identical to the source.
// cmd-grammar-plant.mjs: the typed words for the plant's inverter class, its packing and the study presets.
// inverter central 2500kva 2 central inverters of 2500 kVA, two to a station (MV skid or container)
// inverter string 300kva 20 string inverters of 300 kVA, twenty to a station (the v09 plant)
// packing fields | packing bands | packing band 400 run 280 how the tables fill the land (plant-packing.mjs)
// preset central-6l-20 a generic preset from the UK study (structure-presets.mjs)
// Pure: imports only the presets' names.
import { PRESET_IDS } from './structure-presets.mjs';
export const PLANT_KEYS = Object.freeze({
inverterClass: { label: 'inverter class', choices: ['string', 'central'] },
inverterKVA: { label: 'inverter rating', unit: 'kVA', min: 100, max: 5000 },
invertersPerStation: { label: 'inverters per station', unit: '', min: 1, max: 30, int: true },
packing: { label: 'packing', choices: ['fields', 'bands'] },
bandM: { label: 'distance between east-west tracks', unit: 'm', min: 100, max: 2000 },
runM: { label: 'table run between cross lanes', unit: 'm', min: 30, max: 500 },
hedge: { label: 'hedge setback between fields', unit: 'm', min: 2, max: 10 },
moduleLong: { label: 'module length', unit: 'm', min: 1, max: 2.6 },
moduleShort: { label: 'module width', unit: 'm', min: 0.6, max: 1.4 }
});
export const PLANT_COMMANDS = Object.freeze([
{ verb: 'inverter', usage: 'inverter central 2500kva 2 · inverter string 300kva 20',
words: 'central string inverter skid container combiner box station kva class' },
{ verb: 'packing', usage: 'packing fields · packing bands · packing band 400 run 280',
words: 'fill fields hedges parcels tracks bands runs cross lanes half tables land use' },
{ verb: 'preset', usage: 'preset · preset central-6l-20 · preset uk-dense', words: 'study uk practice operational plant class landscape central' }
]);
export const PLANT_VOCAB = { inverter: ['central', 'string'], packing: ['fields', 'bands', 'band', 'run'] };
// A class switched without a rating takes the class's typical one: central 2500 kVA alone, string 300 kVA twenty.
const CLASS_DEFAULT = { central: [2500, 1], string: [300, 20] };
/** Parses inverter, packing and preset into out (set, act, arg); refusals go to bad. */
export function parsePlant(v, rest, out, { put, bad, isNum }) {
const has = w => rest.includes(w);
if (v === 'inverter') {
const cls = has('central') ? 'central' : has('string') ? 'string' : null, ns = rest.filter(isNum);
const kva = ns.find(x => x.unit === 'kva') || ns.find(x => !x.unit && x.n >= 100), per = ns.find(x => x !== kva && !x.unit);
if (!cls && !kva && !per) { bad.push('inverter takes central or string, a rating in kVA and inverters per station, such as inverter central 2500kva 2'); return; }
if (ns.some(x => x.unit && x.unit !== 'kva')) { bad.push('the inverter rating is in kVA, such as inverter central 2500kva'); return; }
if (cls) put('inverterClass', cls);
const c = cls || null, k = kva ? kva.n : c ? CLASS_DEFAULT[c][0] : null, n = per ? per.n : c ? CLASS_DEFAULT[c][1] : null;
if (k != null) put('inverterKVA', k);
if (n != null) put('invertersPerStation', n);
if (c === 'central' && ((k != null && (k < 500 || k > 5000)) || (n != null && n > 4))) bad.push('a central inverter is 500 to 5000 kVA, 1 to 4 to a station');
if (c === 'string' && ((k != null && (k < 100 || k > 400)) || (n != null && n < 8))) bad.push('a string inverter is 100 to 400 kVA, 8 to 30 to a station');
} else if (v === 'packing') {
if (has('fields')) put('packing', 'fields');
if (has('bands')) put('packing', 'bands');
const at = w => { const i = rest.indexOf(w); return i >= 0 && isNum(rest[i + 1]) ? rest[i + 1].n : null; };
if (at('band') != null) put('bandM', at('band'));
if (at('run') != null) put('runM', at('run'));
if (!Object.keys(out.set).length && !bad.length) bad.push('packing is fields or bands, with band N and run N in metres, such as packing band 400 run 280');
} else if (v === 'preset') {
const w = rest.filter(x => typeof x === 'string').join('').replace(/-/g, ''), id = PRESET_IDS.find(k => k.replace(/-/g, '') === w);
if (w && !id) bad.push(`no preset "${w}"; the presets are ${PRESET_IDS.join(', ')} (type preset for the list)`);
out.act = 'structure'; out.arg = { id: id || null, preset: true };
}
}Cmd Grammar Senses
A JavaScript module in the engine folder of Energy Transition Simulator. It parses senses (`parseSenses`) and is built from the is num helper (`isNum`).
Set aside from the main view: 90% of its lines are the same as solar-design-studio/202609271853-site-world/world/cmd-grammar-senses.mjs (globalgrid2050), which stays. (near-copy-of, proposed by families.py). 90% of lines shared with Cmd Grammar Senses; read that one first. All set-aside files, with reasons. Nothing was deleted.
Evidence
- line-jaccard 0.9048 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-design-studio/202609271853-site-world/world/cmd-grammar-senses.mjs:1-23 e25c7ed1117084e1d79f371885783b12da7178e5
- sha256 ce3be3e6275e1e3f9d14e706368461bd68dd6ab8c1a3a8314ab5562fadee7589
- target sha256 7e8af98f85ccda1e84755897507e8284ab27d10ede17d4342439ad1898717eb7
- group of 3 (identity.json near-copy edges >= 0.9)
- canonical rule: reachable, newest stamp, core repo, most lines
ingestenergy-transition-simulator / prototype/mod/engine/cmd-grammar-senses.mjs · lines 1–25 of 25 · Not reached from any entry point (candidate for review) · pattern parseSenses (shared by 3 files)
- What it does
- Defines isNum, parseSenses.
- Why it exists in the grid workflow
- Domain stage experimental (path word 'prototype'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
- Downstream impact
- Used directly by 1 file: Cmd Grammar (energy-transition-simulator).
- What it achieves
- The binoculars words of the command line (binoculars, zoom, range), split out of `cmd-grammar.mjs` to keep each cartridge under 400 lines.
- Why it matters
- Imported by Cmd Grammar.
- Application
- energy-transition-simulator · prototype/mod/engine · JavaScript module
- Uses
- none found
- Used by
- imported by Cmd Grammar (import)
- Produces
- SENSES_COMMANDS, SENSES_VOCAB, SENSES_ALIASES, parseSenses
- Defines here
- isNum, parseSenses
- 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 prototype/mod/engine/cmd-grammar-senses.mjs:1-25 · blob 12207483f4e38baef201d3340a387f6a107ced06 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: experimental · users: none · canonical: duplicate_candidate
// COPIED UNCHANGED from the v12 world (web/world/cmd-grammar-senses.mjs) at v12 commit 3adcee9 (file last changed b6ebfdb). Modular star family: not known to star-find.
// Do not edit here: change the source and re-copy. Everything below this header is byte-identical to the source.
// cmd-grammar-senses.mjs: the binoculars words of the command line (binoculars, zoom, range), split out of cmd-grammar.mjs
// to keep each cartridge under 400 lines. Pure: parse() hands each verb here with its words. They change no design value
// and stay out of the typed script; the engine (cmd-run.mjs) hands them to senses-mount.mjs.
export const SENSES_COMMANDS = Object.freeze([
{ verb: 'binoculars', usage: 'binoculars on · binoculars off', words: 'binocular lens zoom magnify far horizon look distance rangefinder' },
{ verb: 'zoom', usage: 'zoom 7 · zoom 10', words: 'binoculars magnification lens times' },
{ verb: 'range', usage: 'range', words: 'rangefinder distance bearing height what is under the reticle horizon binoculars' }
]);
export const SENSES_VOCAB = Object.freeze({ binoculars: ['on', 'off'], zoom: ['7x', '10x', 'x'], range: [] });
export const SENSES_ALIASES = Object.freeze([['binocular', 'binoculars'], ['rangefinder', 'range']]);
const STEPS = [7, 10];
const isNum = t => t && typeof t === 'object' && Number.isFinite(t.n);
/** parseSenses(v, rest, bad) -> { act: 'binoculars', arg: { on?, zoom?, range? } } or null (refused; the reason pushed on bad). */
export function parseSenses(v, rest, bad) {
if (v === 'binoculars') return { act: 'binoculars', arg: { on: !rest.includes('off') } };
if (v === 'range') return { act: 'binoculars', arg: { range: true } };
const n = rest.find(isNum), w = rest.find(x => typeof x === 'string' && /^\d+x$/.test(x));
const m = n ? n.n : w ? Number(w.slice(0, -1)) : NaN;
if (!STEPS.includes(m)) { bad.push(`zoom is ${STEPS.join(' or ')} (the binoculars' steps)${Number.isFinite(m) ? `; you typed ${m}` : ''}`); return null; }
return { act: 'binoculars', arg: { zoom: m } };
}