In this section
- Substation Intelligence V9 63 geodesy · code-generator / apps/substation-finder/Si/202609062358-substation-intelligence-v9-63.js lines 2101–2800
Substation Intelligence V9 63
A JavaScript file in the substation finder folder of Code Generator that maps elizabeth line and uses data from the ventus-grid-engine repository. Served with the page at https://ventusltd.github.io/code-generator/apps/substation-finder/Si/.
Set aside from the main view: 100% of its lines are the same as atlas/cartridges/202611180026-substation-intelligence-v9-63.js (gridatlas), which stays. (near-copy-of, proposed by families.py). 99% of lines shared with Substation Intelligence V9 63; read that one first. All set-aside files, with reasons. Nothing was deleted.
Evidence
- line-jaccard 0.9974 to gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 atlas/cartridges/202611180026-substation-intelligence-v9-63.js:1-8609 c6f9632fdb6e803baae03a54a542fe508431d153
- sha256 d94b0de50deddac77643325b10fbe490ce44b8c406dbc6c67e6e7cadbdaa8ec6
- target sha256 88c538b97bf426776cda436151741f17500a2136867d28362407550d72f9038f
- group of 4 (identity.json near-copy edges >= 0.9)
- canonical rule: reachable, newest stamp, core repo, most lines
geodesycode-generator / apps/substation-finder/Si/202609062358-substation-intelligence-v9-63.js · lines 2101–2800 of 8590 · version 2026-09-06 23:58 (continued from section 283) · Not reached from any entry point (candidate for review) · pattern switchOn (shared by 4 files)
- What it does
- It maps elizabeth line, london underground, UK metros trams and hs2. Defines 238 functions or classes, including deepFreeze, escapeHTML, normalizeStatus, fmt, haversine. Side effects: changes the web page (DOM); makes network requests.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'substation'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. Domain terms in the code: 750kV, 400kV, 275kV, 132kV, 66kV, 33kV.
- Inputs & outputs
- In: data source: ventus-grid-engine data; data source: data-federation-map-for-globalgrid2050-all-repos data; data source: spiders data; data source: npm data; GeoJSON file elizabeth_line.geojson; GeoJSON file london_underground.geojson; GeoJSON file uk_metros_trams.geojson; GeoJSON file hs2.geojson. Out: downloaded file gridatlas-; downloaded file globalgrid2050-grid-atlas-; interactive map; canvas drawing; SVG drawing. Voltage levels named: 750kV, 400kV, 275kV, 132kV, 66kV, 33kV, 11kV.
- What it achieves
- It normalizes status (`normalizeStatus`), toggles zone draw mode (`toggleZoneDrawMode`) and opens popup (`openPopup`). ASSEMBLED by `tools/build-cartridge.mjs` from the parts below. Its code works with 400 kV, 100 MVA and 132 kV. It responds to fullscreenchange, webkitfullscreenchange and click events.
- Why it matters
- No other file in the estate was found to import it.
- Application
- code-generator · apps/substation-finder/Si · script
- VEDIC
- SNAP LINE ENDS TO SUBSTATIONS (GG2050-VEDIC-000106): GridAtlas / Substations · Geospatial data processing. line_features, substation_point_features → Line features whose first and last vertices are moved onto the nearest substation point within tolerance; other geometry unchanged.
- VEDIC
- MEASURE (GG2050-VEDIC-000001): GridAtlas / Geodesy · Mathematics / Spherical geometry. coordinate_pair, coordinate_pair → distance_km
- VEDIC
- REPRESENT (GG2050-VEDIC-000002): GridAtlas / Geodesy · Computer science / Geometry processing. geojson_geometry → coordinate_pair_or_null
- Uses
- Spider Full Po Test (estate URL), Data — Grid Studies Public Page (estate URL)
- Used by
- none found
- Produces
- deepFreeze, escapeHTML, normalizeStatus, fmt, haversine, _zoneDrawGetRadius, _zoneDrawCirclePoints, _zoneDrawCalcArea, _zoneDrawUpdateLayers, _zoneDrawShowPopup, _zoneDrawShowPopupDebounced, _zoneDrawClear
- Defines here
- crossing, describe, legality, startNodes, between, within, seasonsOf, flagsFor, at
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- code-generator@3897d83efcd0259d21dce87704b0c33118fe2c2e apps/substation-finder/Si/202609062358-substation-intelligence-v9-63.js:2101-2800 · blob 2c8121b277e1b152a96688f6a2e0d7ef83471376 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, network · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: duplicate_candidate
}
const voltages = [...byVoltage.entries()]
.sort((a, b) => {
if (a[0] === UNDECLARED) return 1;
if (b[0] === UNDECLARED) return -1;
return Number(b[0]) - Number(a[0]);
})
.map(([, band]) => band);
return {
schema: 'gridatlas.module.network-topology.v1',
source: ACCEPTS,
site: {
code: site.code,
name: site.name,
transmission_owner: site.transmission_owner || null,
voltages_kv: Array.isArray(site.voltages_kv) ? site.voltages_kv.slice() : []
},
requested_voltage_kv: wantedKv,
nodes: siteNodes,
by_voltage: voltages,
neighbours: [...neighbours.values()].sort((a, b) => b.circuits - a.circuits),
counts: {
nodes: siteNodes.length,
/* Physical units, deduplicated across the two ends a site may
hold of the same branch. The landing tallies are published
beside them so a reader can see the difference rather than
wonder which number the per-voltage lists add up to. */
circuits: physicalUnits(voltages.flatMap(band => band.circuits)),
transformers: physicalUnits(voltages.flatMap(band => band.transformers)),
planned_changes: physicalUnits(voltages.flatMap(band => band.planned_changes)),
circuit_landings: voltages.reduce((sum, band) => sum + band.circuits.length, 0),
transformer_landings: voltages.reduce((sum, band) => sum + band.transformers.length, 0),
planned_change_landings: voltages.reduce((sum, band) => sum + band.planned_changes.length, 0),
neighbour_sites: neighbours.size
},
counts_are_units: 'A site holds both ends of a transformer and of any '
+ 'internal circuit, so the same branch lands twice. The counts above '
+ 'are physical units; the landing tallies beside them are what the '
+ 'per-voltage lists contain.',
impedance_basis: IMPEDANCE_BASIS,
not_an_assessment: NOT_AN_ASSESSMENT
};
}
return {
schema: 'gridatlas.module.network-topology.v1',
source: ACCEPTS,
counts: {
sites: sitesByCode.size,
nodes: nodes.size,
branch_landings: byNode.size
},
site: resolve,
at,
graph
};
}
NS.networkTopology = Object.freeze({
schema: 'gridatlas.module.network-topology.v1',
accepts: ACCEPTS,
not_an_assessment: NOT_AN_ASSESSMENT,
impedance_basis: IMPEDANCE_BASIS,
index
});
})();
/**
* Module: electrical-distance
*
* How far away a substation is, measured in the network operator's own
* published circuits rather than in kilometres.
*
* WHY THIS EXISTS
* ---------------
* Everything this estate has measured until now has been geometry. The
* geodesy module answers "how many kilometres from this project to that
* substation", and it answers it correctly, to the last place. But a
* kilometre is not a connection. Two substations 7 km apart can be on
* opposite sides of a network boundary with no circuit between them; two
* substations 90 km apart can be the two ends of a single published
* circuit. A map that shows only the first number invites the reader to
* infer the second, and that inference is wrong often enough to be
* dangerous in a document someone spends money on.
*
* So this module answers a different question, from a different source:
* on the network Appendix B actually publishes, how many circuits lie
* between these two sites, and which ones? Every hop is a published row
* with an identity. The answer is a citation, not an estimate.
*
* WHAT IT IS NOT
* --------------
* A hop count is not a distance. Two hops is not "twice as far" as one,
* and a site one hop away is not thereby available to connect to. It is
* not an impedance either: R, X and B are carried on every hop exactly as
* published, and this module contains no arithmetic over them at all -
* summing impedance along a path is the first step of a load flow, and a
* load flow needs a declared model, base values, taps, generation and load
* assumptions, contingencies and validation against a trusted solver. None
* of those are in this file, so neither is the sum.
*
* THE ONE RULE THAT SHAPES THE TRAVERSAL
* --------------------------------------
* A voltage may only change across a transformer, and when it does the
* transformer is named in the path. A circuit whose two ends carry
* different declared voltages is not a voltage change - it is a
* contradiction in the data, and the traversal refuses it and says so
* rather than quietly walking through. Undeclared voltages are carried as
* undeclared and never guessed from a node code.
*
* node tools/proofs/modules/202609012245-electrical-distance.proof.mjs
*/
(() => {
const NS = window.__GRIDATLAS_MODULES__ = window.__GRIDATLAS_MODULES__ || {};
if (NS.electricalDistance) return;
const SCHEMA = 'gridatlas.module.electrical-distance.v1';
const REQUIRES = 'gridatlas.module.network-topology.graph.v1';
const NOT_A_DISTANCE =
'Hops are published circuits between two sites, not a distance. A site '
+ 'one hop away may be a hundred kilometres away, and a site ten '
+ 'kilometres away may be on no shared circuit at all.';
const NOT_A_CAPACITY =
'A path existing on the published network says nothing about whether '
+ 'anything can flow along it for a new project. Ratings are the '
+ 'circuit\'s, not a spare allowance, and queue position, committed '
+ 'connections, consent and commercial terms appear in no appendix.';
const IMPEDANCE_CARRIED =
'R, X and B are reproduced on each hop exactly as published, on a '
+ '100 MVA base. They are not added, scaled or combined anywhere in '
+ 'this module. A sum of them would be the beginning of a load flow, '
+ 'which needs a declared model this data does not contain.';
const UNDECLARED = 'undeclared';
/* A traversal must not invent a voltage, so the two ends of an edge are
compared only when BOTH are declared. */
function crossing(graph, nearNode, farNode) {
const near = graph.nodeVoltageKv(nearNode);
const far = graph.nodeVoltageKv(farNode);
return {
near_kv: near,
far_kv: far,
both_declared: near != null && far != null,
changes: near != null && far != null && near !== far
};
}
function describe(graph, entry, nearNode) {
const farNode = entry.row[entry.far];
const cross = crossing(graph, nearNode, farNode);
return {
kind: entry.kind,
from_node: nearNode,
to_node: farNode,
from_site_code: graph.nodeSiteCode(nearNode) || null,
to_site_code: graph.nodeSiteCode(farNode) || null,
from_voltage_kv: cross.near_kv,
to_voltage_kv: cross.far_kv,
voltage_changed: cross.changes,
/* The transformer's own published ratio, where it has one. Only 140
of 1,472 transformers carry it, so it is reported when present and
never reconstructed from the two node voltages when absent - a
reconstructed ratio would be this module's opinion wearing the
product's authority. */
voltage_ratio_kv: entry.kind === 'transformer'
&& typeof entry.row.voltage_ratio_kv === 'string'
? entry.row.voltage_ratio_kv : null,
/* carried, never computed with */
ratings_mva: graph.ratingsOf(entry.row),
transformer_rating_mva: entry.kind === 'transformer'
&& Number.isFinite(entry.row.rating_mva) ? entry.row.rating_mva : null,
parameters_pct_100mva: graph.parametersOf(entry.row)
};
}
/**
* Is this edge legal to walk?
*
* A transformer is the only thing that may change voltage. A circuit
* that appears to change voltage is a contradiction between two
* published node records, and it is refused and reported rather than
* traversed - a silent walk through it would mix voltages, which is the
* exact failure this estate holds itself to never repeating.
*/
function legality(kind, cross) {
if (!cross.changes) return { legal: true, refusal: null };
if (kind === 'transformer') return { legal: true, refusal: null };
return {
legal: false,
refusal: 'a ' + kind + ' whose two ends carry different declared '
+ 'voltages (' + cross.near_kv + ' kV and ' + cross.far_kv + ' kV); '
+ 'only a transformer may change voltage, so this edge is not walked'
};
}
function startNodes(graph, site, voltageKv) {
const nodes = graph.nodesOfSite(site.code);
if (voltageKv == null) return nodes;
return nodes.filter((name) => graph.nodeVoltageKv(name) === voltageKv);
}
/**
* The shortest published path between two sites, in circuits.
*
* Breadth-first, so the first arrival is a fewest-hop path. Where
* several paths tie, the one found first by sorted node order is
* returned and `ties` says how many others arrived at the same depth,
* because "the" path implies a uniqueness the network does not have.
*
* @param index a network-topology index (must expose graph())
* @param fromKey site code or exact site name
* @param toKey site code or exact site name
* @param options { voltageKv, maxHops }
* @returns a result object, or null if either site is unknown
*/
function between(index, fromKey, toKey, options) {
if (!index || typeof index.graph !== 'function') return null;
const graph = index.graph();
if (!graph || graph.schema !== REQUIRES) return null;
const from = index.site(fromKey);
const to = index.site(toKey);
if (!from || !to) return null;
const opts = options || {};
const voltageKv = Number.isFinite(opts.voltageKv) ? opts.voltageKv : null;
const maxHops = Number.isFinite(opts.maxHops) ? opts.maxHops : 6;
const targets = new Set(graph.nodesOfSite(to.code));
const origins = startNodes(graph, from, voltageKv);
const base = {
schema: SCHEMA,
from: { code: from.code, name: from.name },
to: { code: to.code, name: to.name },
requested_voltage_kv: voltageKv,
max_hops: maxHops,
not_a_distance: NOT_A_DISTANCE,
not_a_capacity: NOT_A_CAPACITY,
impedance_basis: IMPEDANCE_CARRIED
};
if (!origins.length) {
return Object.assign({}, base, {
reached: false,
reason: voltageKv == null
? 'the origin site publishes no nodes in this product'
: 'the origin site publishes no node at ' + voltageKv + ' kV',
hops: null, path: [], refusals: [], ties: 0, explored_nodes: 0
});
}
if (from.code === to.code) {
return Object.assign({}, base, {
reached: true, hops: 0, path: [], refusals: [], ties: 0,
explored_nodes: origins.length,
reason: 'the same site'
});
}
const seen = new Map();
const refusals = [];
let frontier = [];
for (const name of origins.slice().sort()) {
if (targets.has(name)) {
return Object.assign({}, base, {
reached: true, hops: 0, path: [], refusals: [], ties: 0,
explored_nodes: 1,
reason: 'both site codes resolve to the same node'
});
}
seen.set(name, null);
frontier.push(name);
}
for (let depth = 1; depth <= maxHops; depth += 1) {
const next = [];
const arrivals = [];
for (const nearNode of frontier) {
for (const entry of graph.edgesAt(nearNode)) {
const farNode = entry.row[entry.far];
if (!farNode || !graph.has(farNode)) continue;
const cross = crossing(graph, nearNode, farNode);
const verdict = legality(entry.kind, cross);
if (!verdict.legal) {
refusals.push({
at_node: nearNode, to_node: farNode,
kind: entry.kind, reason: verdict.refusal
});
continue;
}
if (seen.has(farNode)) continue;
seen.set(farNode, { via: entry, from: nearNode });
if (targets.has(farNode)) arrivals.push(farNode);
else next.push(farNode);
}
}
if (arrivals.length) {
arrivals.sort();
const path = [];
let cursor = arrivals[0];
while (cursor) {
const step = seen.get(cursor);
if (!step) break;
path.unshift(describe(graph, step.via, step.from));
cursor = step.from;
}
return Object.assign({}, base, {
reached: true,
hops: path.length,
path,
transformers_crossed: path.filter((h) => h.kind === 'transformer').length,
voltage_changes: path.filter((h) => h.voltage_changed).length,
ties: arrivals.length - 1,
refusals,
explored_nodes: seen.size,
arrival_node: arrivals[0]
});
}
if (!next.length) break;
frontier = next.sort();
}
return Object.assign({}, base, {
reached: false,
reason: 'no published path within ' + maxHops + ' hops'
+ (voltageKv == null ? '' : ' from a ' + voltageKv + ' kV node')
+ '; this is a statement about the published network, not about '
+ 'whether the two sites are connected in reality',
hops: null, path: [], refusals, ties: 0, explored_nodes: seen.size
});
}
/**
* Every site reachable within N hops, with the hop count at which it was
* first reached. The neighbourhood a click is actually in, electrically.
*
* @param index a network-topology index
* @param key site code or exact site name
* @param options { hops, voltageKv }
*/
function within(index, key, options) {
if (!index || typeof index.graph !== 'function') return null;
const graph = index.graph();
if (!graph || graph.schema !== REQUIRES) return null;
const site = index.site(key);
if (!site) return null;
const opts = options || {};
const voltageKv = Number.isFinite(opts.voltageKv) ? opts.voltageKv : null;
const limit = Number.isFinite(opts.hops) ? opts.hops : 2;
const origins = startNodes(graph, site, voltageKv);
const seen = new Set(origins);
const bySite = new Map();
const refusals = [];
let frontier = origins.slice().sort();
for (let depth = 1; depth <= limit; depth += 1) {
const next = [];
for (const nearNode of frontier) {
for (const entry of graph.edgesAt(nearNode)) {
const farNode = entry.row[entry.far];
if (!farNode || !graph.has(farNode) || seen.has(farNode)) continue;
const cross = crossing(graph, nearNode, farNode);
const verdict = legality(entry.kind, cross);
if (!verdict.legal) {
refusals.push({ at_node: nearNode, to_node: farNode,
kind: entry.kind, reason: verdict.refusal });
continue;
}
seen.add(farNode);
next.push(farNode);
const code = graph.nodeSiteCode(farNode);
if (!code || String(code).toUpperCase() === String(site.code).toUpperCase()) continue;
if (bySite.has(code)) continue;
const far = graph.siteByCode(code);
bySite.set(code, {
code,
name: far ? far.name : null,
hops: depth,
first_node: farNode,
voltage_kv: cross.far_kv,
via: entry.kind
});
}
}
if (!next.length) break;
frontier = next.sort();
}
const sites = [...bySite.values()].sort((a, b) =>
a.hops - b.hops || String(a.code).localeCompare(String(b.code)));
return {
schema: SCHEMA,
site: { code: site.code, name: site.name },
requested_voltage_kv: voltageKv,
hop_limit: limit,
origin_nodes: origins.length,
sites,
counts: {
sites: sites.length,
by_hop: sites.reduce((acc, s) => {
acc[s.hops] = (acc[s.hops] || 0) + 1;
return acc;
}, {})
},
refusals,
not_a_distance: NOT_A_DISTANCE,
not_a_capacity: NOT_A_CAPACITY
};
}
NS.electricalDistance = Object.freeze({
schema: SCHEMA,
requires: REQUIRES,
not_a_distance: NOT_A_DISTANCE,
not_a_capacity: NOT_A_CAPACITY,
impedance_basis: IMPEDANCE_CARRIED,
undeclared: UNDECLARED,
between,
within
});
})();
/**
* Module: rating-envelope
*
* What the operator publishes a circuit can carry, season by season -
* and a structural refusal to add those numbers up.
*
* WHY THE REFUSAL IS THE FEATURE
* ------------------------------
* A substation with eight 400 kV circuits rated 3,000 MVA each does not
* have 24,000 MVA of anything. The ratings are thermal limits on
* individual branches under stated seasonal conditions; they are not
* additive, they are not simultaneous, and the sum is not a quantity that
* exists in the network. Yet a sum is the single easiest number to
* produce from this data and the single most persuasive to a reader, and
* once printed it is indistinguishable from a capacity figure. That is
* how a published rating becomes an invented headroom number.
*
* So this module reports each circuit's ratings individually, names the
* season each one belongs to, and contains no code path that produces a
* site total. The proof asserts the absence, not merely the intent.
*
* WHAT IT ADDS BEYOND "THE MINIMUM AND THE MAXIMUM"
* -------------------------------------------------
* The owner product already publishes a site-wide winter envelope
* (`circuit_winter_rating_mva.min/max`). Three things it does not do,
* which are done here:
*
* 1. All four seasons, not winter alone. Summer ratings are the binding
* ones for a thermally limited circuit, and the product carries them
* on 1,276 of 1,392 circuits - the 116 without are OFTO-labelled and
* are reported as not published rather than filled in.
*
* 2. Scoped to a voltage. A site-wide range across a 132 kV and a
* 400 kV busbar is a number about no busbar at all.
*
* 3. Implausible values named rather than averaged away. Four circuits
* publish winter_mva of exactly 9999, on spans of a kilometre or
* less with zero impedance; planned changes reach 69,275. These have
* the shape of placeholders, not ratings. A module that quietly
* includes them in a maximum reports a lie with a citation attached,
* so they are carried, flagged, and excluded from the envelope with
* the exclusion stated.
*
* node tools/proofs/modules/202609012250-rating-envelope.proof.mjs
*/
(() => {
const NS = window.__GRIDATLAS_MODULES__ = window.__GRIDATLAS_MODULES__ || {};
if (NS.ratingEnvelope) return;
const SCHEMA = 'gridatlas.module.rating-envelope.v1';
const REQUIRES = 'gridatlas.module.network-topology.graph.v1';
const SEASONS = Object.freeze(['winter', 'spring', 'summer', 'autumn']);
const FIELD = Object.freeze({
winter: 'winter_mva', spring: 'spring_mva',
summer: 'summer_mva', autumn: 'autumn_mva'
});
const NEVER_SUMMED =
'These are per-circuit thermal ratings under stated seasonal '
+ 'conditions. They are not additive and they are not simultaneous: '
+ 'the sum of the circuits at a site is not a quantity that exists in '
+ 'the network, and this module contains no code that produces one.';
const NOT_A_CAPACITY =
'A rating is what a circuit is rated to carry, not what is free on '
+ 'it. Existing flows, committed connections, queue position, outage '
+ 'conditions and commercial terms decide what a project could use, '
+ 'and no published appendix contains any of them.';
/* A rating that is obviously not a rating.
-----------------------------------------------------------------
9999 on a one-kilometre span with zero impedance is a placeholder,
not a thermal limit; so is 69,275 on a hundred-metre cable. The test
is deliberately narrow - a value at or above this threshold is
flagged, nothing else is second-guessed - because a module that
starts judging which published numbers it believes has stopped
reporting the published record. */
const IMPLAUSIBLE_MVA = 9999;
function seasonsOf(row) {
const published = {};
const absent = [];
for (const season of SEASONS) {
const value = row[FIELD[season]];
if (Number.isFinite(value)) published[season] = value;
else absent.push(season);
}
return { published, absent };
}
function flagsFor(published) {
const flags = [];
for (const [season, value] of Object.entries(published)) {
if (value >= IMPLAUSIBLE_MVA) {
flags.push({
season,
value,
reason: 'at or above ' + IMPLAUSIBLE_MVA + ' MVA, which has the '
+ 'shape of a placeholder rather than a thermal rating; it is '
+ 'reported and excluded from the range below'
});
}
}
return flags;
}
/**
* Every circuit landing at a site, at one voltage, with its own
* seasonal ratings. No total anywhere.
*
* @param index a network-topology index exposing graph()
* @param key site code or exact site name
* @param options { voltageKv }
*/
function at(index, key, options) {
if (!index || typeof index.graph !== 'function') return null;
const graph = index.graph();
if (!graph || graph.schema !== REQUIRES) return null;
const site = index.site(key);
if (!site) return null;
const opts = options || {};
const voltageKv = Number.isFinite(opts.voltageKv) ? opts.voltageKv : null;
const nodes = graph.nodesOfSite(site.code)
.filter((name) => voltageKv == null || graph.nodeVoltageKv(name) === voltageKv);
const circuits = [];
const seen = new Set();
for (const nodeName of nodes) {
for (const entry of graph.edgesAt(nodeName)) {
if (entry.kind !== 'circuit') continue;
const far = entry.row[entry.far];
const id = [nodeName, far].sort().join('|');
if (seen.has(id)) continue;
seen.add(id);
const { published, absent } = seasonsOf(entry.row);
if (!Object.keys(published).length) continue;
circuits.push({
from_node: nodeName,
to_node: far,
to_site_code: graph.nodeSiteCode(far) || null,
voltage_kv: graph.nodeVoltageKv(nodeName),
circuit_type: typeof entry.row.circuit_type === 'string' ? entry.row.circuit_type : null,
ohl_km: Number.isFinite(entry.row.ohl_km) ? entry.row.ohl_km : null,
cable_km: Number.isFinite(entry.row.cable_km) ? entry.row.cable_km : null,
ratings_mva: published,
seasons_not_published: absent,
flags: flagsFor(published),
parameters_pct_100mva: graph.parametersOf(entry.row)
});
}
}
circuits.sort((a, b) => String(a.to_node).localeCompare(String(b.to_node)));
/* The per-season RANGE across circuits - a lowest and a highest
rating, which are two real published values - never a sum, and
never a mean, which would be a number no circuit is rated at. */
const by_season = {};
for (const season of SEASONS) {
const values = circuits
.filter((c) => Number.isFinite(c.ratings_mva[season])
&& c.ratings_mva[season] < IMPLAUSIBLE_MVA)
.map((c) => c.ratings_mva[season]);
const excluded = circuits
.filter((c) => Number.isFinite(c.ratings_mva[season])
&& c.ratings_mva[season] >= IMPLAUSIBLE_MVA).length;
by_season[season] = values.length
? {
lowest_circuit_mva: Math.min.apply(null, values),
highest_circuit_mva: Math.max.apply(null, values),
circuits: values.length,
excluded_as_implausible: excluded
}
: { circuits: 0, excluded_as_implausible: excluded, published: false };
}
const flagged = circuits.filter((c) => c.flags.length);
const missingSeasons = circuits.filter((c) => c.seasons_not_published.length);
return {
schema: SCHEMA,
site: { code: site.code, name: site.name },
requested_voltage_kv: voltageKv,
scope: voltageKv == null
? 'every voltage at this site; a range across two busbar voltages '
+ 'is a number about neither of them'
: voltageKv + ' kV nodes at this site only',
circuits,
by_season,
counts: {
circuits: circuits.length,
with_a_flagged_value: flagged.length,
with_a_season_not_published: missingSeasons.length
},
never_summed: NEVER_SUMMED,
not_a_capacity: NOT_A_CAPACITY
};
}
NS.ratingEnvelope = Object.freeze({
schema: SCHEMA,
requires: REQUIRES,
seasons: SEASONS,
implausible_mva: IMPLAUSIBLE_MVA,
never_summed: NEVER_SUMMED,
not_a_capacity: NOT_A_CAPACITY,
at
});
})();
/**
* Module: injection-response
*
* A DECLARED DC power-flow model of the published GB transmission network,
* used to answer one question: if power is injected here, which circuits
* carry it, and what fraction of it does each one carry?
*
* ─────────────────────────────────────────────────────────────────────
* WHY THIS IS A POWER FLOW AND NOT A PRETENDED ONE
* ─────────────────────────────────────────────────────────────────────
*
* The standing rule in this estate has been that R, X and B are carried
* and never computed with, because "the ETYS node/branch dataset is not a
* solved power-flow model merely because it contains R/X/B". That rule is
* right, and it is not repealed here. What it forbids is calling published
* parameters a solution. What it permits - what it was always pointing at -
* is a model that DECLARES itself: states its equations, its base, its
* slack, its assumptions and its validation, and is honest about which
* quantities it cannot produce.
*
* A full AC load flow of GB needs generation and load at every node,
* transformer tap positions, voltage set points, contingency definitions
* and validation against a trusted solver. None of those are published in
* Appendix B, and this module does not invent them, so it does not
* pretend to a load flow.
*
* An INJECTION RESPONSE needs none of them. It is the linear sensitivity
* of branch flows to a transfer between two points - the power-transfer
* distribution factor - and it depends only on the network's topology and
* its series reactances, both of which ARE published. It is the quantity a
* connection engineer wants first: not "what is flowing today", which
* nobody publishes, but "where would my power go".
*
* ─────────────────────────────────────────────────────────────────────
* THE DECLARED MODEL
* ─────────────────────────────────────────────────────────────────────
*
* Equations DC approximation: P = B' · θ, and for each branch
* f_ij = (θ_i − θ_j) / x_ij
* Base 100 MVA, the base the product publishes R/X/B on.
* Reactance x = x_pct_100mva / 100, per unit. Resistance is NOT used:
* the DC approximation neglects it, and saying so is part of
* the declaration.
* Voltages Assumed flat at 1.0 per unit. Not published, not solved.
* Angles Assumed small, so sin θ ≈ θ. Valid for a transmission
* network under normal conditions; it is an approximation
* and it is named as one.
* Losses Zero, by construction of the DC approximation. Real losses
* are of order 1-2% and are not represented.
* Slack DECLARED explicitly, never inferred silently. Every answer
* names the node the power is withdrawn at, because a