In this section
- Secondary Neon Engine geodesy · gridatlas / atlas/modules/202612020205-secondary-neon-engine.js lines 448–1147
Secondary Neon Engine
A JavaScript file in the atlas folder of GridAtlas that maps connection points, GB transmission network, price decade rollup and grid substations, using haversine.
geodesygridatlas / atlas/modules/202612020205-secondary-neon-engine.js · lines 448–1147 of 9008 · version 2026-12-02 02:05 (continued from section 555) · Not reached from any entry point (candidate for review) · pattern isInterconnectorArrival (shared by 3 files)
- What it does
- It maps connection points, GB transmission network, price decade rollup and grid substations. Defines 274 functions or classes, including distanceKm, distanceKm, representativePoint, voltagesKv, destinationPoint. Side effects: changes the web page (DOM); reads or writes files; makes network requests; uses storage (browser storage, DuckDB or Parquet).
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'atlas'): 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, 415kV, 400kV, 275kV, 220kV, 132kV.
- Inputs & outputs
- In: JSON file connection-points.v3.json; JSON file gb-transmission-network.v1.json; JSON file price-decade-rollup.json; GeoJSON file grid_substations.geojson; JSON file neso-connection-sites.lean.json; GeoJSON file interconnectors.geojson; browser storage (getItem); DuckDB queries. Out: browser storage (setItem); interactive map. Coordinate systems named: WGS84 / EPSG:4326. Voltage levels named: 750kV, 415kV, 400kV, 275kV, 220kV, 132kV, 110kV, 66kV.
- What it achieves
- It creates compute observer (`createComputeObserver`), describes compute receipt (`describeComputeReceipt`) and builds stats (`buildStats`). Receipt and distance owner: Ventusltd/ventus-grid-engine. Its code works with 400 kV, 132 kV and 33 kV. It responds to click, keydown and touchstart events.
- Why it matters
- No other file in the estate was found to import it.
- Application
- gridatlas · atlas/modules · script
- 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
- VEDIC
- VOLTAGE (GG2050-VEDIC-000003): GridAtlas / Geodesy · Computer science / Data normalisation. voltage_properties → kilovolt_list
- Uses
- none found
- Used by
- none found
- Produces
- distanceKm, distanceKm, representativePoint, voltagesKv, destinationPoint, initialBearingDeg, copy, finite, located, sameLocation, sameEntity, createComputeObserver
- Defines here
- survey, ready, worksAt, provisional, resolve, nearestTransmission, physicalInputs, buildStats, consistency, stringStats
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 atlas/modules/202612020205-secondary-neon-engine.js:448-1147 · blob 26e5045a356c11088820207d3cbe95eb4b89374f · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, filesystem, network, storage · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
+ geodesy.EARTH_RADIUS_KM + ' km, straight line to mapped geometry'
};
}
NS.gridScope = Object.freeze({
schema: 'gridatlas.module.grid-scope.v2',
CLASS_TOLERANCE_KV,
DEFAULT_BANDS_KM,
CLASSES_KV,
classOf,
scope
});
})();
/**
* Module: source-registry
*
* "Click anywhere on a map and the neons that already work via Pipeline News
* look for cartridges and code." — Vikram, 2026-09-01.
*
* The looking is this module. The Atlas is a composition of cartridges that
* find each other through `window.__GRIDATLAS_*` globals, and the deep scan
* of 1 Sep 2026 found fifteen such surfaces ever registered, thirteen live,
* and nothing anywhere that documents them. Every consumer therefore does
* its own `window.__GRIDATLAS_NETWORK__?.something` and quietly does less
* when the answer is undefined. That is how a click on blank space came to
* report only what OpenStreetMap has mapped, while the cartridge holding
* NESO's 886 published connection points sat loaded in the same page.
*
* So: one registry, declared once, that answers three questions.
*
* WHAT COULD ANSWER the sources this estate knows about, each with
* what it contributes and whether it is required.
* WHAT IS ANSWERING NOW probed live, by looking for the surface AND the
* specific capability, because a cartridge that
* has loaded but not yet fetched is present and
* not yet useful, and those are different states.
* WHAT DID NOT named, with the reason, in the result itself.
*
* The third is the point. A reader who is told "3 of 4 sources answered;
* NESO's published network did not, because its payload had not loaded" can
* judge the answer. A reader shown a shorter answer cannot, and will
* reasonably assume the map has told them everything it knows.
*
* It reads. It never fetches, never renders, and never decides what a
* finding means.
*
* Successor to 202609012135 at generation 202609012217: every source that
* fetches a product declares what it REQUIRES (repository, product, schema)
* and the survey carries that in every state, because a contract stated
* only once the load has succeeded is no help to the reader of a failure.
* The GB price rollup, fetched since v9.41 without a row here, is
* registered with the loader state the sandbox now publishes.
*
* Depends on: nothing.
*/
(() => {
'use strict';
const NS = (window.__GRIDATLAS_MODULES__ = window.__GRIDATLAS_MODULES__ || {});
if (NS.sourceRegistry) return;
/* The registry is DECLARED, not discovered by scanning window.
----------------------------------------------------------------------
Enumerating every __GRIDATLAS_* global would report whatever happens to
be there, including surfaces this estate has never agreed to consume,
and would silently start using a new one the day someone adds it. A
declared list is a contract: adding a source is an edit here, with a
reason, and a proof that the probe actually works. */
const SOURCES = [
{
id: 'map',
surface: '__GRIDATLAS_V9_MAP__',
contributes: 'the map itself: where the click happened, and what is drawn',
probe: (w) => (w.__GRIDATLAS_V9_MAP__ ? 'ready' : 'absent')
},
{
id: 'mapped-substations',
surface: '__GRIDATLAS_NEON_LINKS__',
contributes: 'substations as OpenStreetMap has them mapped, and the '
+ 'measurement the neon links already use',
probe: (w) => {
const links = w.__GRIDATLAS_NEON_LINKS__;
if (!links) return 'absent';
if (typeof links.measure?.distanceKm !== 'function') return 'loaded, cannot measure';
if (!links.substations_loaded) return 'loaded, no substations yet';
return 'ready';
},
detail: (w) => ({ substations: w.__GRIDATLAS_NEON_LINKS__?.substations_loaded || 0 })
},
{
id: 'neso-connection-points',
surface: '__GRIDATLAS_NETWORK__',
requires: { repository: 'Ventusltd/data-grid-gb',
product: 'derived/connection-points.v3.json',
schema: 'data-grid-gb.connection-points.v3' },
contributes: "NESO's published connection points: circuits, transformers, "
+ 'per-voltage fault current and planned changes',
probe: (w) => {
const network = w.__GRIDATLAS_NETWORK__;
if (!network) return 'absent';
if (network.failed) return 'failed to load';
if (!network.loaded) return 'loading';
return 'ready';
},
detail: (w) => ({ connection_points: w.__GRIDATLAS_NETWORK__?.count || null,
schema: w.__GRIDATLAS_NETWORK__?.schema || null })
},
{
id: 'grid-scope',
surface: '__GRIDATLAS_MODULES__.gridScope',
contributes: 'the census of what is mapped around a point, in distance bands',
probe: (w) => (w.__GRIDATLAS_MODULES__?.gridScope ? 'ready' : 'absent')
},
{
id: 'network-topology',
surface: '__GRIDATLAS_MODULES__.networkTopology + __GRIDATLAS_TOPOLOGY__',
requires: { repository: 'Ventusltd/data-grid-gb',
product: 'derived/gb-transmission-network.v1.json',
schema: 'data-grid-gb.transmission-network.v1' },
contributes: 'circuits, transformers, planned changes and neighbouring '
+ 'sites at a named substation, per voltage',
/* Generation 202609012135: the module alone is not the source. At v9.67
this probe said "ready" because the module object existed, while
the ten-megabyte product it indexes had never been fetched by any
cartridge - the module was on disk and answered nothing. Ready now
means the product is indexed; idle means it will load on the first
click that asks; the other states are what the loader says. */
probe: (w) => {
if (!w.__GRIDATLAS_MODULES__?.networkTopology) return 'absent';
const loader = w.__GRIDATLAS_TOPOLOGY__;
if (!loader) return 'module present, no loader in this composition';
if (loader.state === 'ready') return 'ready';
if (loader.state === 'loading') return 'loading';
if (loader.state === 'failed') return 'failed to load';
return 'idle, loads on first use';
},
detail: (w) => ({ sites: w.__GRIDATLAS_TOPOLOGY__?.sites || null,
bytes: w.__GRIDATLAS_TOPOLOGY__?.bytes || null,
schema: w.__GRIDATLAS_TOPOLOGY__?.schema || null })
},
{
id: 'declared-connections',
surface: '__GRIDATLAS_MODULES__.declaredConnections',
contributes: 'points of connection bound to a made Order or a published '
+ 'planning document',
probe: (w) => (w.__GRIDATLAS_MODULES__?.declaredConnections?.count > 0 ? 'ready' : 'absent'),
detail: (w) => ({ records: w.__GRIDATLAS_MODULES__?.declaredConnections?.count || null })
},
{
id: 'gb-electricity-conditions',
surface: '__GRIDATLAS_GB_CONDITIONS__',
contributes: 'the GB wholesale price context a project card carries: '
+ 'negative-price days and the record daily mean, from the owner rollup',
requires: { repository: 'Ventusltd/data-gb-electricity',
product: 'derived/price-decade-rollup.json',
schema: 'data-gb-electricity.price-decade-rollup.v2' },
/* Withheld is its own state: the product was reached and was not the
schema this consumer answers, so the panel shows nothing and says
why. That is neither a failure of the network nor a source ready. */
probe: (w) => {
const loader = w.__GRIDATLAS_GB_CONDITIONS__;
if (!loader) return 'absent';
if (loader.state === 'ready') return 'ready';
if (loader.state === 'loading') return 'loading';
if (loader.state === 'failed') return 'failed to load';
if (loader.state === 'withheld') return 'withheld: ' + String(loader.reason || 'schema not supported');
return 'idle, loads on first use';
},
detail: (w) => ({ schema: w.__GRIDATLAS_GB_CONDITIONS__?.schema || null,
renders: w.__GRIDATLAS_GB_CONDITIONS__?.renders || 0 })
}
];
const READY = 'ready';
/**
* Probe every declared source against a window.
* @param scope the window to read; defaults to this one. Passing it in is
* what lets a proof drive the probe without a browser.
*/
function survey(scope) {
const w = scope || window;
const sources = SOURCES.map((source) => {
let state = 'absent';
let detail = null;
try { state = source.probe(w) || 'absent'; }
catch (error) { state = `probe threw: ${error && error.message}`; }
if (state === READY && typeof source.detail === 'function') {
try { detail = source.detail(w); } catch (_) { detail = null; }
}
return { id: source.id, surface: source.surface,
contributes: source.contributes, requires: source.requires || null,
state, ready: state === READY, detail };
});
const ready = sources.filter(s => s.ready);
const missing = sources.filter(s => !s.ready);
return {
schema: 'gridatlas.module.source-registry.v1',
sources,
ready: ready.map(s => s.id),
missing: missing.map(s => ({ id: s.id, state: s.state })),
counts: { declared: sources.length, ready: ready.length, missing: missing.length },
/* Written as a sentence here so a card cannot compose its own and get
it wrong, and so an absence is never presented as an absence in the
world rather than in this page. */
sentence: missing.length === 0
? `All ${sources.length} sources answered.`
: `${ready.length} of ${sources.length} sources answered. Not answering: `
+ missing.map(s => `${s.id} (${s.state})`).join(', ')
+ '. What they would have added is missing from this answer, not '
+ 'absent from the world.'
};
}
/** Is one source usable right now. */
function ready(id, scope) {
const source = SOURCES.find(s => s.id === id);
if (!source) return false;
try { return source.probe(scope || window) === READY; }
catch (_) { return false; }
}
NS.sourceRegistry = Object.freeze({
schema: 'gridatlas.module.source-registry.v1',
declared: SOURCES.map(s => s.id),
survey,
ready
});
})();
/**
* Module: declared-connections
*
* The 400 kV public record: what each DCO-scale scheme has DECLARED as its
* point of connection, taken from Development Consent Orders, Planning
* Inspectorate documents and public project statements. The table binds a
* register identity (REPD ref) to a NAMED substation, and the functions
* here bind that name to the served payload and measure the distance -
* measured, never asserted.
*
* The rule this exists to keep: bind to the public record or say nothing.
* A nearest-substations list is a measurement; it was listing closer 33 and
* 132 kV points under schemes whose Order names a 400 kV connection, which
* read as connecting them to the wrong network. This table is the answer,
* and it is data with three small functions, so it lives in a module where
* a proof can read every record and a cut can hash it on its own.
*
* WHAT IT WILL NOT DO
* It does not say whether a connection is available, likely or adequate. A
* declared point of connection is a fact about a consent, not a judgement
* about the network. `poc_status` distinguishes a far end that exists from
* one not yet built or under construction, because drawing both the same
* would say something untrue.
*
* Extracted from the sld-sandbox body at generation 202609012128 (UTC),
* record for record; the parity proof reads the previously served bytes
* and asserts the table is unchanged.
*
* Pure. No DOM, no network, no state. Depends on: geodesy.
*/
(() => {
'use strict';
const NS = (window.__GRIDATLAS_MODULES__ = window.__GRIDATLAS_MODULES__ || {});
if (NS.declaredConnections) return;
const geodesy = NS.geodesy;
if (!geodesy) throw new Error('declared-connections requires the geodesy module');
const distanceKm = geodesy.distanceKm;
const RECORDS = Object.freeze({
'10914': { works: "an up to 400 kV substation collating the satellite sites at 132 kV and site generation at 33 kV (Work No. 4A)",
poc_works: "reuse of an ex-generation bay: busbars, a 400 kV 3-phase 4000 A breaker, metering and protection (Work No. 5)",
substation: 'Cottam Substation',
via: 'a new 400 kV scheme substation consented within the DCO',
source: 'Cottam Solar Project Order 2024, granted 5 Sep 2024 (EN010133)' },
'10915': { works: "an up to 400 kV substation collating the satellite sites at 132 kV and site generation at 33 kV (Work No. 4A)",
poc_works: "reuse of an ex-generation bay: busbars, a 400 kV 3-phase 4000 A breaker, metering and protection (Work No. 5)",
substation: 'Cottam Substation',
via: 'a new 400 kV scheme substation consented within the DCO',
source: 'Cottam Solar Project Order 2024, granted 5 Sep 2024 (EN010133)' },
'10916': { works: "an up to 400 kV customer substation at West Burton 3 with reactive power units; up to 132 kV site substations at WB1 and WB2 (Works 3A-3C)",
poc_works: "a new GIS bay by extension of main busbar 4 and reserve busbar 3/4 gas zones (Work No. 4)",
substation: 'West Burton Substation',
via: 'a new 400 kV customer substation at West Burton 3 and a 400 kV cable to the former generator bay',
source: 'West Burton Solar Project Order, granted 24 Jan 2025 (EN010132)' },
'10917': { works: "an up to 400 kV customer substation at West Burton 3 with reactive power units; up to 132 kV site substations at WB1 and WB2 (Works 3A-3C)",
poc_works: "a new GIS bay by extension of main busbar 4 and reserve busbar 3/4 gas zones (Work No. 4)",
substation: 'West Burton Substation',
via: 'a new 400 kV customer substation at West Burton 3 and a 400 kV cable to the former generator bay',
source: 'West Burton Solar Project Order, granted 24 Jan 2025 (EN010132)' },
'9809': { works: "a scheme substation with reactive power units and a 400 kV harmonic filter compound (Work No. 3)",
poc_works: "one new 400 kV generation bay at Cottam (Work No. 4C)",
substation: 'Cottam Substation',
via: 'a new 400 kV scheme substation and a 7.5 km 400 kV underground cable',
source: 'Gate Burton Energy Park Order, granted 2024 (EN010131)' },
'9810': { works: "a scheme substation with reactive power units and a 400 kV harmonic filter compound (Work No. 3)",
poc_works: "one new 400 kV generation bay at Cottam (Work No. 4C)",
substation: 'Cottam Substation',
via: 'a new 400 kV scheme substation and a 7.5 km 400 kV underground cable',
source: 'Gate Burton Energy Park Order, granted 2024 (EN010131)' },
'12281': { works: "two scheme substations, each 2 x 400/33 kV 150/75/75 MVA transformers with 400 kV GIS (Works 3A-3B)",
poc_works: "the standard 400 kV bay kit at a free bay at Cottam (Work No. 5)",
substation: 'Cottam Substation',
via: 'an 18.5 km 400 kV underground cable to a free bay',
source: 'Tillbridge Solar Order 2025 (EN010142)' },
'12282': { works: "two scheme substations, each 2 x 400/33 kV 150/75/75 MVA transformers with 400 kV GIS (Works 3A-3B)",
poc_works: "the standard 400 kV bay kit at a free bay at Cottam (Work No. 5)",
substation: 'Cottam Substation',
via: 'an 18.5 km 400 kV underground cable to a free bay',
source: 'Tillbridge Solar Order 2025 (EN010142)' },
'14806': { poc_status: 'not_built',
poc_status_note: 'the point of connection is NGET\u2019s new substation beside the existing High Marnham, built as Great Grid Upgrade works; the line is drawn to the existing site',
substation: 'High Marnham Substation',
via: "NGET's new substation adjacent to the existing High Marnham (Great Grid Upgrade)",
source: 'One Earth Solar Farm DCO, consented (EN010159)' },
'14807': { poc_status: 'not_built',
poc_status_note: 'the point of connection is NGET\u2019s new substation beside the existing High Marnham, built as Great Grid Upgrade works; the line is drawn to the existing site',
substation: 'High Marnham Substation',
via: "NGET's new substation adjacent to the existing High Marnham (Great Grid Upgrade)",
source: 'One Earth Solar Farm DCO, consented (EN010159)' },
'13599': { works: "up to four 33-400 kV transformers (160 t, up to 15 x 9.5 x 10.5 m each) in a compound of up to 40,000 m2 (ES Ch.2 s2.8)",
poc_works: "a National Grid-delivered extension of Bicker Fen, AIS or GIS, sited for multiple customers (s2.13)",
substation: 'Bicker Fen Substation',
via: 'a 400 kV cable and a consented extension of Bicker Fen shared with Heckington Fen',
source: 'Beacon Fen Energy Park DCO, granted Aug 2026 (EN010151)' },
'13600': { works: "up to four 33-400 kV transformers (160 t, up to 15 x 9.5 x 10.5 m each) in a compound of up to 40,000 m2 (ES Ch.2 s2.8)",
poc_works: "a National Grid-delivered extension of Bicker Fen, AIS or GIS, sited for multiple customers (s2.13)",
substation: 'Bicker Fen Substation',
via: 'a 400 kV cable and a consented extension of Bicker Fen shared with Heckington Fen',
source: 'Beacon Fen Energy Park DCO, granted Aug 2026 (EN010151)' },
'9806': { works: "transformers with bunding and blast walls, switchgear, and harmonic filtering reactive power compensation (Work No. 4)",
poc_works: "a new generation bay plus an AIS-or-GIS extension and a cable sealing end compound at Bicker Fen (Works 6A-6C)",
substation: 'Bicker Fen Substation',
via: 'the consented Bicker Fen extension shared with Beacon Fen',
source: 'Heckington Fen Solar Park DCO, granted (EN010123)' },
'9807': { works: "transformers with bunding and blast walls, switchgear, and harmonic filtering reactive power compensation (Work No. 4)",
poc_works: "a new generation bay plus an AIS-or-GIS extension and a cable sealing end compound at Bicker Fen (Works 6A-6C)",
substation: 'Bicker Fen Substation',
via: 'the consented Bicker Fen extension shared with Beacon Fen',
source: 'Heckington Fen Solar Park DCO, granted (EN010123)' },
'13644': { poc_status: 'under_construction',
poc_status_note: 'a new 400 kV four-bay substation is under construction at Thorpe Marsh',
substation: 'Thorpe Marsh Substation',
via: 'a new 400 kV four-bay substation under construction at Thorpe Marsh',
source: 'public planning and contractor records; construction under way' },
'19801': { poc_status: 'under_construction',
poc_status_note: 'a new 400 kV four-bay substation is under construction at Thorpe Marsh',
substation: 'Thorpe Marsh Substation',
via: 'a new 400 kV four-bay substation under construction at Thorpe Marsh',
source: 'public planning and contractor records; construction under way' },
/* Little Crow is the counter-archetype and belongs here precisely
because it is NOT a 400 kV story: no customer transmission
substation, no long cable, and a point of connection that is a
circuit crossing the site rather than a substation to draw a line
to. Stating that plainly is worth more than drawing nothing. */
'6557': { poc_kind: 'circuit', poc_status: 'existing',
circuit: 'the Keadby \u2013 Broughton \u2013 Teed \u2013 Scawby Brook overhead 132 kV line circuit (Northern Powergrid)',
via: 'a looped connection into an existing 132 kV circuit within the site, with 99.9 MW of export capacity secured',
kv: 132,
source: 'Little Crow Solar Park Grid Network Constraints Report, EN010101, November 2020' },
'7175': { poc_kind: 'circuit', poc_status: 'existing',
circuit: 'the Keadby \u2013 Broughton \u2013 Teed \u2013 Scawby Brook overhead 132 kV line circuit (Northern Powergrid)',
via: 'a looped connection into an existing 132 kV circuit within the site, with 99.9 MW of export capacity secured',
kv: 132,
source: 'Little Crow Solar Park Grid Network Constraints Report, EN010101, November 2020' },
'11928': { substation: 'West Burton Substation',
via: 'a 400 kV grid connection at the former power station site (West Burton C); financial close July 2026',
source: 'public project records' }
});
/* Public works at named substations, shown wherever the name is - the
"customer and NG substations that do not exist yet" half of the logic.
Descriptions of the network, never advice about a scheme. */
const SUBSTATION_WORKS = Object.freeze({
'thorpe marsh substation':
'A new 400 kV four-bay substation is under construction here (public record).',
'high marnham substation':
'NGET is building a new substation adjacent to the existing one (Great Grid Upgrade, public record).',
'bicker fen substation':
'A consented extension here will connect Beacon Fen and Heckington Fen (public record).'
});
const worksAt = (name) => SUBSTATION_WORKS[String(name || '').toLowerCase()] || null;
/* What the Order says is known the moment the identity is known: the
substation, the voltage class, the route, the consented works and the
citation need no payload, no fetch and no map. The distance is the one
part that must be measured, so it is the one part marked pending. */
function provisional(repdRef) {
const declared = RECORDS[String(repdRef || '')];
if (!declared) return null;
if (declared.poc_kind === 'circuit') {
// Nothing to measure to and nothing to draw: say what is declared.
return { poc: declared.circuit, kv: declared.kv || null, at: null,
km: null, pending: false, kind: 'circuit',
poc_status: declared.poc_status || 'existing',
via: declared.via, source: declared.source, works: null,
customer_works: declared.works || null, poc_works: declared.poc_works || null };
}
return {
poc: declared.substation, kv: 400, at: null, km: null, pending: true,
kind: 'substation', poc_status: declared.poc_status || 'existing',
poc_status_note: declared.poc_status_note || null,
via: declared.via, source: declared.source,
works: worksAt(declared.substation),
customer_works: declared.works || null,
poc_works: declared.poc_works || null
};
}
/* Bind the declared name to the served payload. Only a substation of the
declared class (>= 400 kV) with exactly that name counts; a 132 kV site
that happens to share the name is not the point of connection. */
function resolve(repdRef, origin, subs) {
const declared = RECORDS[String(repdRef || '')];
if (!declared) return null;
if (declared.poc_kind === 'circuit') return provisional(repdRef);
const wanted = declared.substation.toLowerCase();
const works = SUBSTATION_WORKS[wanted] || null;
const match = (Array.isArray(subs) ? subs : [])
.filter(s => String(s.name).toLowerCase() === wanted
&& Array.isArray(s.kv) && s.kv[0] >= 400)
.sort((a, b) => b.kv[0] - a.kv[0])[0] || null;
if (!match) {
return { poc: declared.substation, kv: 400, at: null, km: null,
kind: 'substation', poc_status: declared.poc_status || 'existing',
poc_status_note: declared.poc_status_note || null,
via: declared.via, source: declared.source, works,
customer_works: declared.works || null,
poc_works: declared.poc_works || null };
}
return { poc: match.name, kv: Math.round(match.kv[0]), at: match.at,
km: distanceKm(origin[0], origin[1], match.at[0], match.at[1]),
kind: 'substation', poc_status: declared.poc_status || 'existing',
poc_status_note: declared.poc_status_note || null,
via: declared.via, source: declared.source, works,
customer_works: declared.works || null,
poc_works: declared.poc_works || null };
}
/* The nearest transmission (>= 400 kV) substation in the payload, and
separately the nearest one WITH A NAME: an unnamed OSM node can win on
raw distance and the reader still wants an identity. Two measurements,
no judgement about either. */
function nearestTransmission(origin, subs) {
let best = null;
let bestNamed = null;
/* The size of the sample this superlative is drawn from. Counted here
rather than recounted by a caller, because the predicate below is
what decides eligibility and a second implementation of it would
drift from this one. */
let considered = 0;
for (const s of (Array.isArray(subs) ? subs : [])) {
if (!(Array.isArray(s.kv) && s.kv[0] >= 400)) continue;
considered += 1;
const km = distanceKm(origin[0], origin[1], s.at[0], s.at[1]);
if (!best || km < best.km) {
best = { name: s.name || 'Unnamed substation', km, at: s.at };
}
if (s.name && (!bestNamed || km < bestNamed.km)) {
bestNamed = { name: s.name, km, at: s.at };
}
}
if (best) {
best.considered = considered;
best.works = worksAt(best.name);
if (bestNamed && bestNamed.name !== best.name) {
best.named = bestNamed;
best.named.works = worksAt(bestNamed.name);
}
}
return best;
}
NS.declaredConnections = Object.freeze({
schema: 'gridatlas.module.declared-connections.v1',
records: RECORDS,
substationWorks: SUBSTATION_WORKS,
count: Object.keys(RECORDS).length,
isDeclared: (repdRef) => Object.prototype.hasOwnProperty.call(RECORDS, String(repdRef || '')),
worksAt,
provisional,
resolve,
nearestTransmission
});
})();
/**
* Module: sizing-arithmetic
*
* The screening arithmetic of the SLD sandbox: physical inputs to array
* statistics, the three named ratios (design, export, headroom), the
* string and central topologies with their corrected nameplates, the
* finance port of gis-sld-v5-finance.js, and the two-variable fit that
* lands a layout on the capacity the register states.
*
* Lifted out of the sld-sandbox body at generation 202609012205 (UTC),
* expression for expression. The body closed over its state object and
* its finance defaults; here both are parameters. Nothing else changed,
* and the parity proof evaluates the last inline copy beside this module
* on the same inputs and asserts identical values.
*
* WHAT IT WILL NOT DO
* It grades nothing. A ratio below one is stated with its meaning; an
* export set by the transformers is stated as the design fact it is. The
* finance figures are a screening model with the reference's own inputs
* and are labelled as such by the panel that shows them.
*
* Pure. No DOM, no network, no state of its own: fitToStatedCapacity
* mutates the state object it is handed, as the body's did, and says so.
*/
(() => {
const NS = window.__GRIDATLAS_MODULES__ = window.__GRIDATLAS_MODULES__ || {};
if (NS.sizingArithmetic) return;
function physicalInputs(inputs) {
const i = inputs;
if (i.mode === 'central') {
return {
mod_wp: i.mod_wp_c, mod_l: i.mod_l_c, mod_w: i.mod_w_c,
gcr: i.gcr_c, gross_factor: i.gross_factor_c,
};
}
return {
mod_wp: i.mod_wp, mod_l: i.mod_l, mod_w: i.mod_w,
gcr: i.gcr, gross_factor: i.gross_factor,
};
}
function buildStats(inputs, o) {
const p = physicalInputs(inputs);
const dcMwp = (o.module_count * p.mod_wp) / 1e6;
const acMw = o.ac_mw_direct != null ? o.ac_mw_direct
: (o.dc_ac_ratio > 0 ? dcMwp / o.dc_ac_ratio : 0);
const netModArea = o.module_count * p.mod_l * p.mod_w;
const netArrayArea = p.gcr > 0 ? netModArea / p.gcr : 0;
return {
total_blocks: o.total_blocks,
module_count: o.module_count,
dc_mwp: dcMwp,
ac_mw: acMw,
dc_ac_ratio: acMw > 0 ? dcMwp / acMw : o.dc_ac_ratio,
net_array_area_m2: netArrayArea,
gross_site_area_m2: netArrayArea * p.gross_factor,
block_ground_area_m2: o.total_blocks > 0 ? netArrayArea / o.total_blocks : 0,
production_substation_ac_mva: o.production_substation_ac_mva || 0,
ring_main_ac_mva: o.ring_main_ac_mva || 0,
warning: o.warning || 'Check skid rating, transformer rating, cable ratings, protection, losses and grid compliance.'
};
}
/* Three numbers that must agree, and did not.
----------------------------------------------------------------------
Measured on the shipped defaults, the panel produced three different
values for one quantity:
string stated DC/AC input 1.200
reported DC/AC 1.040
implied by the hardware 0.945
A DC/AC ratio below one is not a design choice, it is a contradiction: it
says the array is smaller than the inverters it feeds, which nobody
builds. And in central mode the reported ratio was 2.402 against an
inverter ratio of 1.200 — exactly double, because AC had correctly become
the LIMITING nameplate (the transformers) while the ratio was still being
read as though it were the inverter nameplate. Both numbers were right
about different things and both were called DC/AC.
There are three distinct quantities here and the panel now keeps them
apart by name:
DC the array, MWp
inverter AC the inverters can convert, MW
export the smaller of the inverters and the transformers, MVA
The DESIGN ratio is DC over inverter AC, which is the number the industry
means by DC/AC and the one a stated 1.2 refers to. The EXPORT ratio is DC
over the export limit, which is what determines clipping and curtailment.
Reporting one of them under the other's name is how a plant ends up
described as 2.4 when it was specified as 1.2.
Nothing here changes a layout. It changes what the numbers are called, and
says so out loud when they disagree with each other. */
/* There was an auto-reconciler here. It is deleted, not disabled.
----------------------------------------------------------------------
It computed a "consistent" strings-per-inverter count from the stated
DC/AC ratio and assigned it to sld.inputs.z_strings, on the reasoning that
the original's 18 gives a block DC/AC of 0.945 and that nobody builds an
array smaller than its own inverters. That reasoning was wrong: the
reference documents 28 string inverters at 352 kVA making 9,856 kVA ahead
of an 8.96 MVA skid, and the oversizing is the design.
The default was reverted, and the reconciler was left behind uncalled.
Flagged by the Codex source gate as a stop-ship, and it was right. Dead
code that ASSIGNS to a reference input is not inert: it is one future
handler away from silently rewriting the design this cartridge exists to
reproduce, and it would do so quietly, in a place nobody would look.
This is the same lesson as the dead .grid-cell grading CSS removed from
Pipeline News earlier tonight — a rule with no caller is one edit from
having one — and I repeated the mistake within hours of writing it down.
Deleted rather than commented out, for the same reason. */
function consistency(inputs, stats) {
const i = inputs;
const string = i.mode === 'string';
const inverterAcMw = string
? (stats.total_blocks * i.y_invs * i.string_inv_kva) / 1000
: stats.total_blocks * i.inv_ac_mw_c;
const skidAcMva = string
? stats.total_blocks * i.string_skid_mva
: (i.mv_per_ring_c * i.rings_c) * i.central_skid_mva_c;
const exportMva = Math.min(inverterAcMw, skidAcMva);
/* Three ratios, three names. They describe different pairs of things and
collapsing them is how a plant specified at 1.2 gets reported as 2.4.
design array DC MWp / inverter AC MW what "DC/AC" means
export array DC MWp / export MVA what drives clipping
headroom inverter AC MW / export MVA how hard the inverters are
pushed against their skids
The third is the one that says whether the inverters are oversized
against the transformers, and in this design they deliberately are. */
const designRatio = inverterAcMw > 0 ? stats.dc_mwp / inverterAcMw : null;
const exportRatio = exportMva > 0 ? stats.dc_mwp / exportMva : null;
const headroomRatio = exportMva > 0 ? inverterAcMw / exportMva : null;
const statedRatio = string ? Number(i.dc_ac_ratio) : (
i.inv_ac_mw_c > 0 ? i.inv_dc_mw_c / i.inv_ac_mw_c : null);
const notes = [];
/* Descriptive, not a verdict.
An earlier version of this called a design ratio below one a
contradiction that "nobody builds". That was wrong about this design:
the reference sandbox documents 28 string inverters at 352 kVA making
9,856 kVA ahead of an 8.96 MVA skid, and oversizing inverters against
the transformer is a deliberate choice, not an arithmetic fault. The
panel states the number and what it means; it does not grade it. */
if (Number.isFinite(designRatio) && designRatio < 1) {
notes.push('Array DC divided by inverter AC is ' + designRatio.toFixed(2)
+ ' from the module, string and inverter counts shown.');
}
// The stated ratio is an instruction. If the hardware does not honour it,
// the hardware is what will be built.
if (Number.isFinite(designRatio) && Number.isFinite(statedRatio)
&& statedRatio > 0 && Math.abs(designRatio - statedRatio) / statedRatio > 0.05) {
notes.push('Stated DC/AC ' + statedRatio.toFixed(2) + ', but the module '
+ 'and inverter counts give ' + designRatio.toFixed(2)
+ '. The model displays both and does not rewrite either input.');
}
// The transformers, not the inverters, set the export.
if (Number.isFinite(inverterAcMw) && Number.isFinite(skidAcMva)
&& inverterAcMw > skidAcMva * 1.001) {
// Stated as the design fact it is, with the ratio, not as a fault.
notes.push('Inverters total ' + inverterAcMw.toFixed(1) + ' MW against '
+ skidAcMva.toFixed(1) + ' MVA of skid transformer, a ratio of '
+ (headroomRatio || 0).toFixed(2) + '. Export is set by the '
+ 'lower nameplate in this screening model. The connection agreement '
+ 'and electrical design determine the applicable export constraint.');
}
return {
dc_mwp: stats.dc_mwp,
inverter_ac_mw: inverterAcMw,
skid_ac_mva: skidAcMva,
export_mva: exportMva,
design_dc_ac: designRatio,
export_dc_ac: exportRatio,
inverter_to_export: headroomRatio,
stated_dc_ac: Number.isFinite(statedRatio) ? statedRatio : null,
notes,
};
}
function stringStats(inputs) {
const i = inputs;
if (i.mod_wp <= 0 || i.mod_l <= 0 || i.mod_w <= 0 || i.x_mods <= 0) {
return buildStats(i, { total_blocks: 0, module_count: 0, dc_ac_ratio: i.dc_ac_ratio });
}
const total_blocks = i.b_cols * i.s_subs;
const module_count = total_blocks * i.y_invs * i.z_strings * i.x_mods;
const inverterAcMaxMva = (i.y_invs * i.string_inv_kva) / 1000;
const production = i.string_skid_mva;
let warning;
if (inverterAcMaxMva > production) {
warning = 'Inverter ACmax exceeds the skid transformer rating. Verify temperature rating, overload strategy and clipping assumptions.';
} else if (i.string_inv_kva > 500) {
warning = 'Large string inverter rating selected. Verify LV switchgear, transformer, cable loading and protection.';
}
return buildStats(i, {
total_blocks, module_count, dc_ac_ratio: i.dc_ac_ratio,
ac_mw_direct: total_blocks * production,
production_substation_ac_mva: production,