In this section
- Single-Line Diagram (SLD) Sandbox V9 8 geodesy · globalgrid2050 / testcode/202609051152/atlas/cartridges/202609050354-sld-sandbox-v9-8.js lines 701–1400
Single-Line Diagram (SLD) Sandbox V9 8
A JavaScript file in the cartridges folder of GlobalGrid2050 that maps connection points, GB transmission network, price decade rollup and grid substations, using haversine.
Set aside from the main view: 95% of its lines are the same as testcode/202609060300/atlas/cartridges/202609060300-sld-sandbox.js (globalgrid2050), which stays. (near-copy-of, proposed by families.py). 95% of lines shared with Single-Line Diagram (SLD) Sandbox; read that one first. All set-aside files, with reasons. Nothing was deleted.
Evidence
- line-jaccard 0.9509 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 testcode/202609060300/atlas/cartridges/202609060300-sld-sandbox.js:1-7736 b9451a6d240116dae04211c0cc8216a75da78ad1
- sha256 7c2df5dabb0082d4cef941b98bf31e92161d1e79a7d22bd6c84e81b171507022
- target sha256 93d81bebf3d1cf8f799ccf6f117f1565777ed88110481c284713589539586605
- group of 2 (identity.json near-copy edges >= 0.9)
- canonical rule: reachable, newest stamp, core repo, most lines
geodesyglobalgrid2050 / testcode/202609051152/atlas/cartridges/202609050354-sld-sandbox-v9-8.js · lines 701–1400 of 7382 · version 2026-09-05 03:54 (continued from section 339) · Not reached from any entry point (candidate for review) · pattern widerFleetBuckets (shared by 6 files)
- What it does
- It maps connection points, GB transmission network, price decade rollup and grid substations. Defines 217 functions or classes, including classOf, scope, survey, ready, worksAt. 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 experimental (path word 'sandbox'): 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: 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; browser storage (getItem); DuckDB queries; form fields (user input). 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 builds stats (`buildStats`), applies development stage defaults (`applyDevelopmentStageDefaults`) and applies mounting bifacial (`applyMountingBifacial`). ASSEMBLED by `tools/build-cartridge.mjs` from the parts below. 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
- globalgrid2050 · testcode/202609051152/atlas/cartridges · script
- VEDIC
- MEASURE (GG2050-VEDIC-000001): GridAtlas / Geodesy · Mathematics / Spherical geometry. coordinate_pair, coordinate_pair → distance_km
- VEDIC
- VOLTAGE (GG2050-VEDIC-000003): GridAtlas / Geodesy · Computer science / Data normalisation. voltage_properties → kilovolt_list
- VEDIC
- REPRESENT (GG2050-VEDIC-000002): GridAtlas / Geodesy · Computer science / Geometry processing. geojson_geometry → coordinate_pair_or_null
- Uses
- none found
- Used by
- mentioned in Standalone (comment link)
- Produces
- classOf, scope, survey, ready, worksAt, provisional, resolve, nearestTransmission, physicalInputs, buildStats, consistency, stringStats
- Defines here
- buildStats, consistency, stringStats, centralStats, financeNumber, applyDevelopmentStageDefaults, applyMountingBifacial, screeningFinance, computeStats, fitToStatedCapacity, oneMore
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 testcode/202609051152/atlas/cartridges/202609050354-sld-sandbox-v9-8.js:701-1400 · blob f66bb0bcbf98ce7cd519581375865ca92f816b61 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, filesystem, network, storage · domain stage: experimental · users: none · canonical: unreached_review
}
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,
ring_main_ac_mva: production * i.s_subs,
warning
});
}
function centralStats(inputs) {
const i = inputs;
if (i.mod_wp_c <= 0 || i.mod_l_c <= 0 || i.mod_w_c <= 0 || i.x_mods_c <= 0) {
return buildStats(i, { total_blocks: 0, module_count: 0, dc_ac_ratio: 1.2 });
}
const strDcKwp = (i.x_mods_c * i.mod_wp_c) / 1000;
const reqStrings = strDcKwp > 0 ? Math.ceil((i.inv_dc_mw_c * 1000) / strDcKwp) : 0;
// total_blocks counts INVERTERS: inverters per MV skid, times skids per
// ring, times rings. The skids are the level above it.
const total_blocks = i.inv_per_mv_c * i.mv_per_ring_c * i.rings_c;
const skid_count = i.mv_per_ring_c * i.rings_c;
const module_count = reqStrings * i.x_mods_c * total_blocks;
/* Two nameplates, and they are not the same number.
--------------------------------------------------------------------
The inverters and the MV skid transformers they share are rated
separately, and the plant can export no more than the smaller of the
two. On the shipped defaults they are a factor of two apart: 24
inverters at 4.4 MW is 105.6 MW of inverter, sitting on 12 skids at
4.4 MVA, which is 52.8 MVA of transformer.
The figure shown was 211.2 MW -- neither of those, and larger than
both. `total_blocks` already contains `inv_per_mv_c`, and the AC line
multiplied by it a second time, so the count of inverters sharing a
skid entered the answer squared. It also multiplied a count of
inverters by a TRANSFORMER rating, which is not a quantity that
exists.
This is a deliberate divergence from the sandbox this was ported from.
gis-sld-v5-calculations.js line 147 computes the same expression, so
the fault is in the original and was carried across faithfully by a
port whose whole contract was to carry the arithmetic unchanged.
Reported by the Codex session auditing this estate in parallel;
confirmed here dimensionally and against those defaults. */
const inverter_ac_total = total_blocks * i.inv_ac_mw_c;
const skid_ac_total = skid_count * i.central_skid_mva_c;
const ac_mw_direct = Math.min(inverter_ac_total, skid_ac_total);
// A skid carries every inverter fed into it, so the comparison that
// matters is the whole MV block against its transformer, not one
// inverter against it. One-to-one it never fires; on the defaults the
// block is 8.8 MW on a 4.4 MVA skid and it should.
const block_ac_mw = i.inv_ac_mw_c * i.inv_per_mv_c;
let warning;
if (block_ac_mw > i.central_skid_mva_c) {
warning = `The ${i.inv_per_mv_c} inverters on each MV skid total `
+ `${block_ac_mw.toFixed(2)} MW against a skid rated `
+ `${i.central_skid_mva_c} MVA. Export is limited by the transformer, `
+ `not the inverters. Verify thermal rating, overload strategy and `
+ `the export limit in the connection agreement.`;
} else if (i.inv_ac_mw_c > 10) {
warning = 'Large central inverter or power block selected. Verify transformer, MV switchgear, harmonics, thermal loading, protection and grid code compliance.';
}
return buildStats(i, {
total_blocks, module_count,
dc_ac_ratio: i.inv_ac_mw_c > 0 ? i.inv_dc_mw_c / i.inv_ac_mw_c : 1.2,
ac_mw_direct,
// One skid's rating. The label on the control is "Skid MVA", so it is
// the skid, and multiplying it by the inverters on that skid described
// no piece of equipment.
production_substation_ac_mva: i.central_skid_mva_c,
ring_main_ac_mva: i.central_skid_mva_c * i.mv_per_ring_c,
central_inverter_ac_total: inverter_ac_total,
central_skid_ac_total: skid_ac_total,
warning
});
}
const DEVELOPMENT_STAGES = Object.freeze({
'0.003': 'Land Option Signed',
'0.015': 'Grid Connection Application Accepted',
'0.035': 'Planning Application Submitted',
'0.055': 'Planning Permission Granted',
'0.070': 'Grid Connection Terms Reviewed and Agreed',
'0.080': 'Buyer or Revenue Agreement Reviewed (Power Purchase Agreement (PPA) / Offtaker)',
'0.100': 'Construction Contract Signed and Finance Committed (Financial Close)',
});
const financeNumber = value => {
const number = Number(value);
return Number.isFinite(number) ? number : 0;
};
const DEVELOPMENT_SUCCESS = Object.freeze({
'0.003': 10,
'0.015': 15,
'0.035': 30,
'0.055': 55,
'0.070': 70,
'0.080': 80,
'0.100': 95,
});
const BIFACIAL_BY_GCR = Object.freeze({
'0.35': 8,
'0.45': 5,
'0.75': 2,
});
/* The original stage selector is not only a label: its change handler sets
development cost to the selected GBP/Wp value and success probability to
a stage-specific percentage. Keep that linked behavior explicit so a
stage change cannot leave the old stage's costs behind. */
function applyDevelopmentStageDefaults(financeInputs, stageValue) {
const stage = String(stageValue);
if (!Object.prototype.hasOwnProperty.call(DEVELOPMENT_STAGES, stage)) return false;
financeInputs.dev_stage = stage;
financeInputs.dev_cost_mw = financeNumber(stage);
financeInputs.dev_success = DEVELOPMENT_SUCCESS[stage];
return true;
}
/* Original Mounting & GCR presets also set the financial bifacial gain.
Apply the exact three preset mappings to the active topology only. A
free-form GCR value does not invent a gain. */
function applyMountingBifacial(financeByMode, mode, gcrValue) {
const values = (financeByMode || {})[mode];
if (!values) return false;
const key = String(Number(gcrValue));
if (!Object.prototype.hasOwnProperty.call(BIFACIAL_BY_GCR, key)) return false;
values.bifacial = BIFACIAL_BY_GCR[key];
return true;
}
/* Direct port of gis-sld-v5-finance.js computeFinance(). The original
executable fixture is the authority, not this comment. The one deliberate
divergence is inherited from the corrected electrical port: annual OPEX
uses the corrected central inverter nameplate, so the inv_per_mv > 1 case
must match the fixture's explicit corrected surplus rather than repeat the
original AC double-count. Every unaffected output remains exact. */
function screeningFinance(financeInputs, stats, context) {
const f = financeInputs || (context && context.defaults) || {};
const dcMwp = financeNumber(stats?.dc_mwp);
// The reference's OPEX input is GBP/MWac/year. In string mode its AC
// quantity is skid-limited export. In central mode, once the known square
// is removed, it is inverter count x inverter MWac. Do not silently swap
// that to transformer-limited export: those are separately named values.
const centralInverterAc = (stats?.mode || (context && context.fallbackMode)) === 'central'
? financeNumber(stats?.consistency?.inverter_ac_mw) : 0;
const acMw = centralInverterAc > 0 ? centralInverterAc : financeNumber(stats?.ac_mw);
const price = financeNumber(f.price);
const other = financeNumber(f.other);
const yieldVal = financeNumber(f.yield);
const bifacial = financeNumber(f.bifacial);
const baseLoss = financeNumber(f.losses);
const deg = financeNumber(f.deg);
const opexRate = financeNumber(f.opex);
const epcEx = financeNumber(f.epc_ex);
const floodRate = financeNumber(f.flood_rate);
const floodAdder = f.flood ? floodRate : 0;
const modules = financeNumber(f.modules);
const otherCapex = financeNumber(f.other_capex);
const fixedCapex = financeNumber(f.fixed_capex);
const cont = financeNumber(f.cont);
const lossExtras = financeNumber(f.loss_dc_string) + financeNumber(f.loss_lv_dc)
+ financeNumber(f.loss_lv_ac) + financeNumber(f.loss_tx) + financeNumber(f.loss_other);
const totalLoss = baseLoss + lossExtras;
const bessMw = financeNumber(f.bess_mw);
const bessMwh = financeNumber(f.bess_mwh);
const bessCapexRate = financeNumber(f.bess_capex);
const bessCycles = financeNumber(f.bess_cycles);
const bessRevenuePerMwh = financeNumber(f.bess_spread);
const bessEffPercent = financeNumber(f.bess_eff);
const safeLoss = Math.min(Math.max(totalLoss, 0), 100);
const safeBessEff = Math.min(Math.max(bessEffPercent / 100, 0), 1);
const effectiveYield = yieldVal * (1 + bifacial / 100);
const year1Gen = dcMwp * effectiveYield * (1 - safeLoss / 100);
let gen25 = 0;
let gen35 = 0;
for (let year = 1; year <= 35; year += 1) {
const generation = year1Gen * Math.pow(1 - deg / 100, year - 1);
if (year <= 25) gen25 += generation;
gen35 += generation;
}
const annualSolarRevenue = year1Gen * (price + other);
const bessAnnualValue = bessMwh * bessCycles * bessRevenuePerMwh * safeBessEff;
const annualRevenue = annualSolarRevenue + bessAnnualValue;
const revenue25 = gen25 * (price + other) + bessAnnualValue * 25;
const revenue35 = gen35 * (price + other) + bessAnnualValue * 35;
const annualOpex = acMw * opexRate;
const baseCapexWp = epcEx + modules + otherCapex + floodAdder;
const baseCapex = dcMwp * 1_000_000 * baseCapexWp;
const contingency = baseCapex * (cont / 100);
const bessCapex = bessMwh * bessCapexRate;
const totalCapex = baseCapex + contingency + fixedCapex + bessCapex;
const capexPerWp = dcMwp > 0 ? totalCapex / (dcMwp * 1_000_000) : 0;
const surplus25 = revenue25 - annualOpex * 25 - totalCapex;
const surplus35 = revenue35 - annualOpex * 35 - totalCapex;
const devCostPerMw = financeNumber(f.dev_cost_mw);
const devModulePerMwp = financeNumber(f.dev_module_mwp);
const devEpcPerMw = financeNumber(f.dev_epc_mw);
const devOwnerPerMw = financeNumber(f.dev_owner_mw);
const devGridPerMw = financeNumber(f.dev_grid_mw);
const devExitPerMwp = financeNumber(f.dev_exit_mwp);
const devNpvPerMwp = financeNumber(f.dev_npv_mwp);
const devSuccessPct = financeNumber(f.dev_success);
const devYears = financeNumber(f.dev_years);
const devStage = DEVELOPMENT_STAGES[String(f.dev_stage)] || 'Manual';
const wpCapacity = dcMwp * 1_000_000;
const devCapitalAtRisk = wpCapacity * devCostPerMw;
const devModuleCost = wpCapacity * devModulePerMwp;
const devEpcCost = wpCapacity * devEpcPerMw;
const devOwnerCost = wpCapacity * devOwnerPerMw;
const devGridCost = wpCapacity * devGridPerMw;
const devTotalBuildCost = devCapitalAtRisk + devModuleCost + devEpcCost
+ devOwnerCost + devGridCost;
const devExitValue = wpCapacity * devExitPerMwp;
const devOperatingNpv = wpCapacity * devNpvPerMwp;
const devGrossMargin = devExitValue - devTotalBuildCost;
const devRiskAdjustedValue = devGrossMargin * (devSuccessPct / 100);
const devReturnMultiple = devCapitalAtRisk > 0 ? devGrossMargin / devCapitalAtRisk : 0;
return {
annualRevenue, revenue25, revenue35, totalCapex, capexPerWp, surplus25, surplus35,
devStage, devCostPerMw, devModulePerMwp, devEpcPerMw, devOwnerPerMw,
devGridPerMw, devExitPerMwp, devNpvPerMwp, devSuccessPct, devYears,
devCapitalAtRisk, devModuleCost, devEpcCost, devOwnerCost, devGridCost,
devTotalBuildCost, devExitValue, devOperatingNpv, devGrossMargin,
devRiskAdjustedValue, devReturnMultiple, price, other, yieldVal, bifacial,
baseLoss, deg, opexRate, epcEx, floodActive: Boolean(f.flood), floodRate,
modules, otherCapex, fixedCapex, cont, totalLoss, bessMw, bessMwh,
bessCapexRate, bessCycles, bessSpread: bessRevenuePerMwh,
bessEff: bessEffPercent, epcIncModules: epcEx + modules,
};
}
function computeStats(inputs, financeByMode, defaults) {
const stats = inputs.mode === 'string'
? stringStats(inputs) : centralStats(inputs);
// Same object, so nothing can read a capacity without the check that says
// whether the capacities agree with each other.
stats.mode = inputs.mode;
stats.consistency = consistency(inputs, stats);
stats.finance = screeningFinance((financeByMode || {})[inputs.mode], stats,
{ fallbackMode: inputs.mode, defaults });
return stats;
}
/**
* Size the array so its capacity lands on the figure the register states.
*
* WHAT IS ADJUSTED, AND WHAT IS NOT
* Two integer topology counts move -- circuits and skids per circuit in
* string mode, rings and MV skids per ring in central mode. Everything a
* supplier fixes stays where the user put it:
* module rating, string length, inverter and skid ratings. That keeps the
* result buildable rather than a number reverse-engineered into nonsense.
*
* Blocks are integers, so an exact hit is usually impossible. The residual
* is reported rather than hidden, because a layout that quietly lands 7%
* off the stated capacity is worse than one that says so.
*
* WHICH CAPACITY IS BEING MATCHED
* That is the caller's declared basis, never a guess. REPD's figure is
* nominally MWelec, but it is reported inconsistently: some schemes state
* DC, some AC, and the register does not carry the distinction reliably.
* Matching AC when the figure was DC oversizes the connection by the DC/AC
* ratio, which is exactly the error that matters for export limitation.
*/
/* Fit on two variables, because one cannot reach a small project.
----------------------------------------------------------------------
Reported: the numbers do not change when the headline capacity changes.
Measured, and they do not:
string 5, 10, 20, 30, 40, 49.9 and 50 MW all produced 44.80 MW
central 5, 10 and 20 MW all produced 17.60 MW
The fit moved ONE variable. In string mode that is b_cols, and because
total_blocks is b_cols x s_subs with s_subs pinned at five, one step of
b_cols is five blocks — 44.8 MW at the default skid rating. Nothing below
that is reachable, so a 30 MW solar farm was drawn as a 44.8 MW one, an
overstatement of half as much again, and every target under 50 MW
collapsed onto the same layout. The register starts at 1 MW.
A block is 8.96 MW in string mode and a skid is 4.4 MVA in central. Those
are the real quanta, and they are reachable as soon as the inner variable
is allowed to move too. So the search is over both, and it prefers the
candidate that stays closest to the shape the user already had — a fit
that reaches the right capacity by rearranging the whole plant is a worse
answer than one that reaches it by adding a column.
Bounds are physical rather than generous: a ring main carries a handful of
skids, not four hundred, so the inner variable stops at twelve. */
const FIT_OUTER_MAX = 120;
const FIT_INNER_MAX = 12;
function fitToStatedCapacity(sld, computeSldStats) {
sld.fitResidualPct = null;
sld.fitQuantumMw = null;
const target = Number(sld.targetMw);
if (!Number.isFinite(target) || target <= 0) return;
if (sld.targetBasis !== 'ac' && sld.targetBasis !== 'dc') return;
const string = sld.inputs.mode === 'string';
const outerKey = string ? 'b_cols' : 'rings_c';
const innerKey = string ? 's_subs' : 'mv_per_ring_c';
const outer0 = sld.inputs[outerKey];
const inner0 = sld.inputs[innerKey];
let best = null;
for (let inner = 1; inner <= FIT_INNER_MAX; inner += 1) {
sld.inputs[innerKey] = inner;
for (let outer = 1; outer <= FIT_OUTER_MAX; outer += 1) {
sld.inputs[outerKey] = outer;
const s = computeSldStats();
const got = sld.targetBasis === 'ac' ? s.ac_mw : s.dc_mwp;
if (!Number.isFinite(got) || got <= 0) continue;
const error = Math.abs(got - target);
// Ties, and near-ties, go to the layout closest to the one already on
// screen. Without this the fit rearranges the plant for a rounding
// difference and the drawing jumps for no reason the user can see.
const drift = Math.abs(inner - inner0) + Math.abs(outer - outer0) / 100;
if (!best
|| error < best.error - 1e-9
|| (Math.abs(error - best.error) <= 1e-9 && drift < best.drift)) {
best = { outer, inner, error, got, drift };
}
}
}
if (!best) {
sld.inputs[outerKey] = outer0;
sld.inputs[innerKey] = inner0;
return;
}
sld.inputs[outerKey] = best.outer;
sld.inputs[innerKey] = best.inner;
sld.fitResidualPct = ((best.got - target) / target) * 100;
// What one more block would have added. A residual means nothing without
// it: 10% off a plant whose smallest step is 9 MW is exact, and 10% off
// one whose step is 0.5 MW is a miss.
const oneMore = (() => {
sld.inputs[outerKey] = best.outer + 1;
const s = computeSldStats();
sld.inputs[outerKey] = best.outer;
const got = sld.targetBasis === 'ac' ? s.ac_mw : s.dc_mwp;
return Number.isFinite(got) ? Math.abs(got - best.got) : null;
})();
sld.fitQuantumMw = oneMore;
}
NS.sizingArithmetic = Object.freeze({
generation: '202609012205',
DEVELOPMENT_STAGES,
DEVELOPMENT_SUCCESS,
BIFACIAL_BY_GCR,
FIT_OUTER_MAX,
FIT_INNER_MAX,
financeNumber,
physicalInputs,
buildStats,
consistency,
stringStats,
centralStats,
applyDevelopmentStageDefaults,
applyMountingBifacial,
screeningFinance,
computeStats,
fitToStatedCapacity
});
})();
/* ══════════════════════════════════════════════════════════════════════
technology-coverage - which technologies the measurement runs for, and
what each measurement is a measurement OF
══════════════════════════════════════════════════════════════════════
WHAT WAS MEASURED BEFORE THIS MODULE WAS WRITTEN.
The request was to extend the nearest-substation computation to the twenty
wider-fleet REPD technologies, on the report that it ran only for the
spine. Driven in Chrome against the live composition (v9.88, generation
202609030234) on the wider fleet's own MAP link:
?repd_ref=8795 ... &technology=biomass Caledon Green, Landfill Gas
?repd_ref=626 ... &technology=biomass Pitsea Tipp, Landfill Gas
Both arrived, flew, opened the card, ticked the Subs control and DREW THE
LINKS. Caledon Green measured 1.74 km at 132 kV, 2.98 km at 275 kV and
5.70 km at 33 kV; Pitsea Tipp named Coryton South Substation at 7.70 km
and printed its 400 kV scope sentence with the denominator in it. So the
wider fleet was ALREADY computing, and a change that claimed to enable it
would have been a change that did nothing while saying it did something.
There IS a four-member technology allow-list in this estate:
const allowedTechnologies = new Set(['solar','bess','wind_onshore','wind_offshore']);
It lives at line 805 of the IMMUTABLE SHELL, atlas/releases/
202608300453-atlas-v9/ventus-corev8engine.js, inside the shell's own
focusCanonicalProjectDeepLink(). It rejects every value the wider fleet
can send, because those four are exactly the four types the wider fleet is
DEFINED as excluding. Its rejection is caught, and its only effects are a
console line and a flyTo the arrival lane in this cartridge has already
performed - which is why the measurement runs anyway. The shell is carried
forward verbatim by contract and this module does not reach into it.
WHAT THIS MODULE ACTUALLY CHANGES.
One thing: OFFSHORE WIND NOW MEASURES. It used to open a card and withhold
the distance, on the reasoning that a turbine in the North Sea does not
reach the nearest onshore substation by a straight line. The reasoning
about routes was right and is kept in full below; the conclusion was
over-cautious. An offshore project's export cable does land at an onshore
substation, so the distance to the nearest mapped substation is a real
measurement of a real thing, provided the card says what it measured.
WHAT "NEAREST" CANNOT BE MADE TO MEAN HERE, MEASURED RATHER THAN ASSUMED.
The coordinator asked for an onshore-only filter, so that "nearest onshore
substation" would mean onshore. The pinned substation product cannot carry
one. Counted over all 5,800 features of
atlas/releases/202608300453-atlas-v9/data/grid_substations.geojson
the only properties present are voltage (5,800), name (4,460), operator
(3,264), brand (1,310), source (684), type (72), capacity (15) and colour
(3). The OSM `location` tag - the field that would say offshore, platform
or underwater - is present on ZERO of them.
That leaves the name, and the name does not separate them either. Fourteen
features carry "offshore" in their name; read against their coordinates, at
least four are ONSHORE substations serving an offshore wind farm, which is
precisely what an offshore project should be measured to - Hornsea
(-0.2598, 53.6582) and Hornsea Two (-0.2604, 53.6568) at 400/220 kV,
Thanet's explicitly-named onshore substation (1.3459, 51.3089), and the
European Offshore Wind Deployment Centre (-2.0650, 57.2158). The rest are
genuinely platforms at sea: Neart na Gaoithe North and South, Sheringham
Shoal 1 and 2, Humber Gateway, Westermost Rough, Rampion, Burbo Bank 2.
So a name filter would drop Hornsea - a landfall connection - from the very
search it was supposed to sharpen. No onshore filter is applied, and this
module says so on the card instead of pretending to one. An offshore
project is measured against the SAME 5,800 features, at the SAME >=33 kV
floor, by the SAME straight line as every other technology, and the card
carries two extra sentences: that the line crosses water and is not the
export cable, and that the set searched contains substations that are
themselves offshore - named where one is returned, so the reader can see
which. A stated limit, rather than a hidden one. A filter whose predicate
is wrong four times in fourteen is worse than no filter, because it looks
like precision.
WHAT DOES NOT CHANGE, AND MUST NOT.
- The straight line stays. It is the measurement, it is first, and the
corridor-estimate module still sits beside it saying how far off a
built route typically is. Nothing here replaces it.
- Every superlative keeps carrying its sample. This module supplies the
sample LABEL for each policy so the card cannot print "nearest"
without printing what it searched.
- The coordinate denominator stays. The operator publishes connection
points and only a fraction carry coordinates; that count is computed
at render time by nearestScope() and is not restated here, because a
literal would go quietly false the day the pinned product moves.
- Nothing here grades anything. No verdict word appears anywhere in this
module, not even to disown one: the sandbox proof greps the served
bytes for them and cannot tell a comment from a card, which is the
right way round. A distance and a voltage, stated, and the things a
distance cannot answer named rather than implied.
THE ROSTER IS BY NAME ON PURPOSE.
The Atlas never receives a raw REPD technology. Pipeline News' MAP link
sends `technology=<t>`, the COLOUR BUCKET - so twenty raw types arrive as
nine bucket values, and "Landfill Gas" reaches this cartridge as
"biomass". Every one of the twenty is listed below against its bucket, so
a proof can assert coverage by REPD name rather than by bucket, and so
anyone reading this can see that the twenty are accounted for rather than
assumed.
══════════════════════════════════════════════════════════════════════ */
(function installTechnologyCoverage() {
'use strict';
const SCHEMA = 'gridatlas.technology-coverage.v1';
/* The twenty wider-fleet REPD technologies, each against the bucket the
MAP link actually sends. Counts are the live wider-fleet payload,
202609030009, 1,104 rows - carried so a drift in either side is visible
rather than silent. Every one of the 1,104 rows carries a usable
coordinate pair; none is withheld for want of a location. */
const WIDER_FLEET = Object.freeze([
Object.freeze({ repd: 'Landfill Gas', bucket: 'biomass', rows: 275 }),
Object.freeze({ repd: 'Anaerobic Digestion', bucket: 'biomass', rows: 253 }),
Object.freeze({ repd: 'Biomass (dedicated)', bucket: 'biomass', rows: 159 }),
Object.freeze({ repd: 'EfW Incineration', bucket: 'biomass', rows: 122 }),
Object.freeze({ repd: 'Small Hydro', bucket: 'hydro', rows: 108 }),
Object.freeze({ repd: 'Hydrogen', bucket: 'hydrogen', rows: 60 }),
Object.freeze({ repd: 'Advanced Conversion Technologies', bucket: 'act', rows: 37 }),
Object.freeze({ repd: 'Large Hydro', bucket: 'hydro', rows: 28 }),
Object.freeze({ repd: 'Pumped Storage Hydroelectricity', bucket: 'hydro', rows: 15 }),
Object.freeze({ repd: 'Tidal Stream', bucket: 'tidal', rows: 14 }),
Object.freeze({ repd: 'Sewage Sludge Digestion', bucket: 'biomass', rows: 12 }),
Object.freeze({ repd: 'Geothermal', bucket: 'geothermal', rows: 5 }),
Object.freeze({ repd: 'Shoreline Wave', bucket: 'tidal', rows: 4 }),
Object.freeze({ repd: 'Liquid Air Energy Storage', bucket: 'caes', rows: 2 }),
Object.freeze({ repd: 'Biomass (co-firing)', bucket: 'biomass', rows: 2 }),
Object.freeze({ repd: 'Hot Dry Rocks (HDR)', bucket: 'geothermal', rows: 2 }),
Object.freeze({ repd: 'Compressed Air Energy Storage', bucket: 'caes', rows: 2 }),
Object.freeze({ repd: 'Fuel Cell (Hydrogen)', bucket: 'hydrogen', rows: 2 }),
Object.freeze({ repd: 'Flywheels', bucket: 'flywheel', rows: 1 }),
Object.freeze({ repd: 'Unknown', bucket: 'other', rows: 1 })
]);
/* The spine, for completeness: the four the wider fleet is defined as
excluding, and the four the shell's allow-list accepts. */
const SPINE = Object.freeze(['solar', 'bess', 'wind_onshore', 'wind_offshore']);
/* Offshore wind, in every spelling the register and the engine use. This
is no longer a withholding set - it selects a DIFFERENT NOTE, not a
different answer. */
const OFFSHORE_TECHS = Object.freeze([
'wind_offshore', 'wind_offshore_operational'
]);
const OFFSHORE = new Set(OFFSHORE_TECHS);
/* Named as offshore in the substation product. Used only to LABEL a
returned row, never to remove one - see the header for the four onshore
substations this pattern also matches, which is exactly why it does not
filter. */
const OFFSHORE_NAMED = /\boffshore\b/i;
const ONSHORE_NAMED = /\bonshore\b/i;
const PRODUCT = Object.freeze({
features: 5800,
with_location_tag: 0,
offshore_in_name: 14,
of_those_onshore: 4,
source: 'atlas/releases/202608300453-atlas-v9/data/grid_substations.geojson'