In this section
- Firm Capacity energy-data · ventus-grid-engine / engine/firm-capacity.js lines 1–209
- Power Factor electrical · ventus-grid-engine / engine/power-factor.js lines 1–191
- Published Fault Level electrical · ventus-grid-engine / engine/published-fault-level.js lines 1–250
Firm Capacity
A JavaScript module in Ventus Grid Engine that works with transformers and substations, using IEC 60076-7.
energy-dataventus-grid-engine / engine/firm-capacity.js · lines 1–209 of 209 · pattern requirePositive (shared by 2 files)
- What it does
- It calculates transformers and substations. Defines 7 functions or classes, including requirePositive, requireRatio, requireUnits, apparentPowerMva, firmCapacityMva.
- Why it exists in the grid workflow
- Domain terms in the code: transformers, substations.
- Downstream impact
- Used directly by 8 files: Grid Engine — Substation Growth Page (globalgrid2050, https://globalgrid2050.com/grid_engine/202609060218-substation-growth/); Build Graph (ventus-grid-engine, https://ventusltd.github.io/ventus-grid-engine/genome/); Firm Capacity Proof (ventus-grid-engine); Grid Engine — Firm Capacity Page (globalgrid2050, https://globalgrid2050.com/grid_engine/202609060205-firm-capacity/); and 4 more. Reached from 4 other entry points, including Homepage V090 (globalgrid2050, https://globalgrid2050.com/homepage_versions/homepage_v090.html); Homepage V091 (globalgrid2050, https://globalgrid2050.com/homepage_versions/homepage_v091.html); Homepage V093 (globalgrid2050, https://globalgrid2050.com/homepage_versions/homepage_v093.html).
- What it achieves
- It is built from the require positive helper (`requirePositive`), the require ratio helper (`requireRatio`) and the require units helper (`requireUnits`). What a substation can carry when one unit is out. Its code works with 30 MVA, 100 MW and 105.3 MVA.
- Why it matters
- Loaded by the Substation Growth page in GlobalGrid2050 at https://globalgrid2050.com/grid_engine/202609060218-substation-growth/ and 5 other pages. Also imported by Build Graph and Firm Capacity Proof.
- Application
- ventus-grid-engine · engine · JavaScript module
- VEDIC
- CHECK FIRM CAPACITY (GG2050-VEDIC-000070): Ventus Grid Engine · Energy and power calculation. transformer_ratings_mva, stated_demand_mva → Firm and installed MVA, demand shortfall in MVA, and whether demand fits each capacity.
- Uses
- none found
- Used by
- linked from Grid Engine — Substation Growth Page (link), named by URL in Build Graph (estate URL), imported by Firm Capacity Proof (import), linked from Grid Engine — Firm Capacity Page (link), linked from Grid Engine — Data Centre Connection Page (link), linked from Grid Engine — EV Depot Page (link), linked from Grid Engine — Compute Against Charging Page (link), linked from Grid Engine — Every Home a Charger Page (link)
- Produces
- schema, apparentPowerMva, firmCapacityMva, utilisationAgainstRating, assessAgainstFirm, NOT_COMPUTED
- Defines here
- requirePositive, requireRatio, requireUnits, apparentPowerMva, firmCapacityMva, utilisationAgainstRating, assessAgainstFirm
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- ventus-grid-engine@ad566356a44e006682e956483d569f31ddbb9630 engine/firm-capacity.js:1-209 · blob 8c87c71f29cc27970305c3109efeb22b66fbe568 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: unknown · users: none · canonical: production_core
/**
* Module: firm-capacity
*
* APPLIED ENGINEERING. What a substation can carry when one unit is out.
*
* WHY THIS IS THE FIRST QUESTION A PLANNER ASKS.
* A substation's nameplate is the sum of its transformers. Its FIRM capacity
* is what remains when the largest single unit is unavailable, because a
* network planned to N-1 must survive the loss of any one element without
* shedding load. Two 30 MVA transformers are a 60 MVA site with 30 MVA of firm
* capacity. A site loaded to 42 MVA is comfortable on nameplate and already
* beyond firm — it is running on the assumption that nothing breaks. That gap
* between installed and firm is where most connection refusals actually live,
* and it is invisible if you only look at the total.
*
* WHY MVA AND NOT MW.
* Transformers and cables are limited by current, and current is set by
* apparent power, not real power. A 100 MW load at 0.95 power factor draws
* 105.3 MVA and it is the 105.3 that the plant has to carry. Sizing on MW
* silently under-counts by the reciprocal of the power factor — 5% here, more
* for a poorer load. Every rating in this module is therefore in MVA, and
* converting from MW requires a power factor the caller states.
*
* N-1 AND WHAT IT IS NOT.
* The rule implemented here is the ordinary planning one: firm capacity is the
* total less the largest single unit. That is what a two- or three-transformer
* distribution substation means by firm. It is NOT a substitute for a security
* study: real security standards (ER P2/7 in GB) set the required restoration
* time and permitted interruption by group demand, allow for transfer capacity
* from adjacent sites, and count generation and storage contributions under
* stated conditions. A site can pass this arithmetic and fail P2/7, and it can
* fail this arithmetic and still be compliant because load transfers away.
* The functions say so in their basis text rather than leaving the caller to
* assume otherwise.
*
* CYCLIC AND EMERGENCY RATINGS ARE NOT MODELLED, DELIBERATELY.
* A transformer will carry more than its nameplate for a period, set by its
* thermal time constant, its oil and winding temperatures, the ambient, and
* how much life the owner will spend. That is a real and routinely used margin
* — and it belongs to the owner's asset policy and IEC 60076-7 loading guide,
* not to a screening tool. Passing one nameplate figure in and getting a
* bigger number out would misrepresent an engineering judgement as arithmetic.
*
* WHAT THIS MODULE REFUSES.
* There is no function returning spare capacity, headroom, or whether a
* connection can be made. Utilisation against a rating the CALLER supplies is
* arithmetic and is offered. Inferring availability from it is not, because
* the binding constraint is frequently somewhere else entirely — the upstream
* circuit, the fault level at the busbar, a voltage step, or a commercial
* position in a queue. The proof asserts these functions are absent.
*
* Depends on: nothing. Pure arithmetic on caller-supplied ratings.
*
* Schema: ventus-grid-engine.firm-capacity.v1
*/
export const schema = 'ventus-grid-engine.firm-capacity.v1';
function requirePositive(name, value) {
if (typeof value !== 'number' || !Number.isFinite(value)) {
throw new TypeError(`${name} must be a finite number, received ${value === null ? 'null' : typeof value}`);
}
if (value <= 0) throw new RangeError(`${name} must be greater than zero, received ${value}`);
return value;
}
function requireRatio(name, value) {
requirePositive(name, value);
if (value > 1) {
throw new RangeError(
`${name} must be a fraction in (0, 1], received ${value}. A percentage such as 95 must be passed as 0.95.`
);
}
return value;
}
function requireUnits(units) {
if (!Array.isArray(units) || units.length === 0) {
throw new TypeError('units must be a non-empty array of transformer ratings in MVA');
}
units.forEach((u, i) => requirePositive(`units[${i}]`, u));
return units;
}
/**
* Apparent power from real power and a stated power factor.
*
* S (MVA) = P (MW) / pf
*
* The conversion plant is actually rated for.
*/
export function apparentPowerMva({ mw, powerFactor }) {
requirePositive('mw', mw);
requireRatio('powerFactor', powerFactor);
return {
schema,
quantity: 'apparent_power_mva',
value: mw / powerFactor,
unit: 'MVA',
from: { mw, powerFactor },
basis:
`Plant is limited by current, and current follows apparent power: ${mw} MW at a power ` +
`factor of ${powerFactor} draws the MVA stated. Sizing on MW alone under-counts by ` +
`1/pf — here that is ${(((1 / powerFactor) - 1) * 100).toFixed(1)}%.`
};
}
/**
* Installed and firm capacity for a set of transformers.
*
* Firm is the total less the largest single unit — the ordinary N-1 planning
* rule. A single-transformer site has zero firm capacity, and that is the
* correct and important answer, not an error.
*/
export function firmCapacityMva({ units }) {
requireUnits(units);
const installed = units.reduce((a, b) => a + b, 0);
const largest = Math.max(...units);
const firm = installed - largest;
return {
schema,
quantity: 'firm_capacity_mva',
value: firm,
unit: 'MVA',
from: { units: [...units], installedMva: installed, largestUnitMva: largest, unitCount: units.length },
basis: units.length === 1
? `A single ${largest} MVA transformer has NO firm capacity: losing it loses the site. ` +
`Installed capacity is ${installed} MVA and firm capacity is zero. That is the answer, not a fault.`
: `N-1: ${units.length} units totalling ${installed} MVA, less the largest single unit ` +
`(${largest} MVA), leaves ${firm} MVA with any one unit out. This is the ordinary ` +
`planning rule, not a security study — ER P2/7 also counts transfer capacity from ` +
`adjacent sites and permits interruption by group demand, so a site can pass this and ` +
`fail that, or fail this and remain compliant because load transfers away.`
};
}
/**
* Utilisation of a demand against a rating the caller supplies.
*
* Arithmetic on two stated numbers. Deliberately NOT called headroom: see the
* header, and the refusal text returned alongside.
*/
export function utilisationAgainstRating({ demandMva, ratingMva }) {
requirePositive('demandMva', demandMva);
requirePositive('ratingMva', ratingMva);
const ratio = demandMva / ratingMva;
return {
schema,
quantity: 'utilisation_of_stated_rating',
value: ratio,
unit: 'dimensionless',
percent: ratio * 100,
exceedsRating: ratio > 1,
from: { demandMva, ratingMva },
basis:
`${demandMva} MVA against a stated rating of ${ratingMva} MVA is ` +
`${(ratio * 100).toFixed(1)}% of that rating` +
(ratio > 1
? `, which EXCEEDS it by ${(demandMva - ratingMva).toFixed(2)} MVA.`
: `.`) +
` This is a ratio of two figures you supplied. It is not spare capacity and not a ` +
`connection assessment: the binding constraint is frequently elsewhere — the upstream ` +
`circuit, the fault level at the busbar, a voltage step, or a position in a queue.`
};
}
/**
* The N-1 question in the form a planner actually asks it: does this demand
* still sit inside firm capacity, and by how much does it miss if not?
*/
export function assessAgainstFirm({ units, demandMva }) {
const firm = firmCapacityMva({ units });
requirePositive('demandMva', demandMva);
const installed = firm.from.installedMva;
const withinFirm = demandMva <= firm.value;
const withinInstalled = demandMva <= installed;
return {
schema,
quantity: 'n_minus_one_assessment',
withinFirm,
withinInstalled,
firmMva: firm.value,
installedMva: installed,
demandMva,
shortfallMva: withinFirm ? 0 : demandMva - firm.value,
utilisationOfFirm: demandMva / firm.value,
utilisationOfInstalled: demandMva / installed,
basis: withinFirm
? `${demandMva.toFixed(2)} MVA sits inside the ${firm.value} MVA firm capacity: the site carries ` +
`this demand with any one unit out.`
: withinInstalled
? `${demandMva.toFixed(2)} MVA is inside the ${installed} MVA installed but BEYOND the ` +
`${firm.value} MVA firm capacity, short by ${(demandMva - firm.value).toFixed(2)} MVA. ` +
`The site carries this demand only while nothing is out. This is the gap that most ` +
`often decides a connection, and it is invisible if you look only at the total.`
: `${demandMva.toFixed(2)} MVA exceeds even the ${installed} MVA installed capacity.`
};
}
export const NOT_COMPUTED = Object.freeze({
spareCapacity:
'Spare capacity is the network operator\'s figure, from its model, its running arrangement and its outage plan. A rating minus a demand is not it.',
connectionAvailability:
'Whether a connection can be made is answered by an application and an offer. The binding constraint is often the upstream circuit, the fault level or a queue position, none of which appear in this arithmetic.',
cyclicAndEmergencyRating:
'A transformer carries more than nameplate for a period, set by its thermal time constants, the ambient and how much insulation life the owner will spend. That is the owner\'s asset policy under IEC 60076-7, not a screening calculation.',
securityCompliance:
'ER P2/7 compliance depends on group demand, permitted interruption, restoration time and transfer capacity from adjacent sites. Passing the N-1 arithmetic here neither demonstrates nor refutes it.'
});Power Factor
A JavaScript module in Ventus Grid Engine that works with transformers and cables.
electricalventus-grid-engine / engine/power-factor.js · lines 1–191 of 191 · pattern positive (shared by 12 files)
- What it does
- It calculates transformers and cables. Defines 7 functions or classes, including positive, powerFactor, tanPhi, reactivePowerKvar, apparentPowerKva.
- Why it exists in the grid workflow
- Domain terms in the code: transformers, cables.
- Downstream impact
- Used directly by 3 files: Build Graph (ventus-grid-engine, https://ventusltd.github.io/ventus-grid-engine/genome/); Power Factor Proof (ventus-grid-engine); Grid Engine — Power Factor Page (globalgrid2050, https://globalgrid2050.com/grid_engine/202609060309-power-factor/). Reached from 4 other entry points, including Homepage V090 (globalgrid2050, https://globalgrid2050.com/homepage_versions/homepage_v090.html); Homepage V091 (globalgrid2050, https://globalgrid2050.com/homepage_versions/homepage_v091.html); Homepage V093 (globalgrid2050, https://globalgrid2050.com/homepage_versions/homepage_v093.html).
- What it achieves
- It is built from the positive step (`positive`), the power factor helper (`powerFactor`) and the tan phi helper (`tanPhi`). How much reactive power a load draws, what it costs in capacity, and how much of that capacity correction gives back. Its code works with 156 kVA.
- Why it matters
- Loaded by the page of the same name in GlobalGrid2050 at https://globalgrid2050.com/grid_engine/202609060309-power-factor/. Also imported by Build Graph and Power Factor Proof.
- Application
- ventus-grid-engine · engine · JavaScript module
- VEDIC
- REACTIVE (GG2050-VEDIC-000020): Ventus Grid Engine / power-factor · Electrical engineering / Applied mathematics. real_power_kw, power_factor → reactive_power_kvar
- VEDIC
- APPARENT (GG2050-VEDIC-000021): Ventus Grid Engine / power-factor · Electrical engineering / Applied mathematics. real_power_kw, power_factor → apparent_power_kva
- VEDIC
- CORRECT (GG2050-VEDIC-000022): Ventus Grid Engine / power-factor · Electrical engineering / Applied mathematics. real_power_kw, initial_pf, target_pf → correction_and_capacity_record
- Uses
- none found
- Used by
- named by URL in Build Graph (estate URL), imported by Power Factor Proof (import), linked from Grid Engine — Power Factor Page (link)
- Produces
- schema, reactivePowerKvar, apparentPowerKva, correctionKvar, againstAgreedCapacity, NOT_COMPUTED
- Defines here
- positive, powerFactor, tanPhi, reactivePowerKvar, apparentPowerKva, correctionKvar, againstAgreedCapacity
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- ventus-grid-engine@ad566356a44e006682e956483d569f31ddbb9630 engine/power-factor.js:1-191 · blob 84ca845b75979df96f5069287b00de421b50b22b · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: unknown · users: none · canonical: production_core
/**
* Module: power-factor
*
* APPLIED ENGINEERING. How much reactive power a load draws, what it costs in
* capacity, and how much of that capacity correction gives back.
*
* WHY THIS IS THE CHEAPEST CAPACITY ANYBODY EVER BUYS.
* Plant is limited by current, and current follows apparent power. A 1,000 kW
* load at 0.85 power factor draws 1,176 kVA; the same load corrected to 0.98
* draws 1,020 kVA. The site has not reduced its consumption by a single
* kilowatt-hour, and it has released 156 kVA of transformer and cable capacity.
* Where a connection is the constraint — which, for anyone trying to electrify
* behind an existing supply, it usually is — that is capacity obtained without
* an application, a reinforcement, or a wait.
*
* THE ARITHMETIC, WHICH IS TRIGONOMETRY AND NOTHING CLEVERER.
* Real power P, reactive power Q and apparent power S form a right triangle:
*
* S = sqrt(P^2 + Q^2) pf = cos(phi) = P / S Q = P x tan(phi)
*
* Correcting from pf1 to pf2 means supplying the difference in reactive power
* locally instead of drawing it across the network:
*
* Qc = P x (tan(phi1) - tan(phi2))
*
* That is the size of the correction equipment, in kVAr. It is exact, and it is
* the whole of what this module computes.
*
* WHY UNITY IS NOT THE TARGET, AND WHY THE MODULE WILL NOT PICK ONE.
* Correcting to exactly 1.0 is usually wrong: the last few percent costs
* disproportionately, an over-corrected site exports reactive power and can be
* charged for it, and a fixed bank on a varying load will over-correct at part
* load. Networks and tariffs generally reward somewhere around 0.95 to 0.98,
* and the right figure depends on the tariff and the load profile. So the
* target is an input here and there is no default.
*
* WHAT THIS MODULE REFUSES.
* It does not design a capacitor bank. Real correction equipment has to be
* assessed for harmonic resonance with the supply impedance — an installation
* can amplify existing harmonic voltages badly enough to destroy itself and
* the plant around it — and that needs a harmonic study with the network
* operator's data. It does not calculate a reactive power charge, because
* tariffs differ by network and change. It does not decide whether correction
* is worth doing, which is a commercial question with a payback in it.
*
* Schema: ventus-grid-engine.power-factor.v1
*/
export const schema = 'ventus-grid-engine.power-factor.v1';
function positive(name, v) {
if (typeof v !== 'number' || !Number.isFinite(v)) {
throw new TypeError(`${name} must be a finite number, received ${v === null ? 'null' : typeof v}`);
}
if (v <= 0) throw new RangeError(`${name} must be greater than zero, received ${v}`);
return v;
}
function powerFactor(name, v) {
positive(name, v);
if (v > 1) throw new RangeError(
`${name} must be a fraction in (0, 1], received ${v}. A power factor of 95% must be passed as 0.95.`);
return v;
}
/* tan(arccos(pf)), the reactive power per unit of real power. Written from the
identity rather than through two trig calls, so it is exact at pf = 1 where
arccos returns a value whose tangent is a floating-point approximation of
zero. */
function tanPhi(pf) {
return Math.sqrt(1 - pf * pf) / pf;
}
/**
* The reactive power a load draws at a stated power factor.
*/
export function reactivePowerKvar({ kw, powerFactor: pf }) {
positive('kw', pf === undefined ? kw : kw);
powerFactor('powerFactor', pf);
return {
schema,
quantity: 'reactive_power_kvar',
value: kw * tanPhi(pf),
unit: 'kVAr',
from: { kw, powerFactor: pf },
basis:
`${kw} kW at a power factor of ${pf} draws ${(kw * tanPhi(pf)).toFixed(1)} kVAr of reactive ` +
`power. Reactive power does no work, but it is carried by the same conductors and occupies ` +
`the same plant rating as the real power beside it.`
};
}
/**
* Apparent power, which is what the plant is actually rated for.
*/
export function apparentPowerKva({ kw, powerFactor: pf }) {
positive('kw', kw);
powerFactor('powerFactor', pf);
return {
schema,
quantity: 'apparent_power_kva',
value: kw / pf,
unit: 'kVA',
from: { kw, powerFactor: pf },
basis:
`${kw} kW at ${pf} is ${(kw / pf).toFixed(1)} kVA. This is the figure the transformer, the ` +
`cable and the agreed capacity are all measured against.`
};
}
/**
* The correction needed to move from one power factor to another, and the
* capacity that releases.
*
* Both power factors are the caller's. There is no default target: see the
* header on why unity is usually the wrong answer.
*/
export function correctionKvar({ kw, fromPowerFactor, toPowerFactor }) {
positive('kw', kw);
powerFactor('fromPowerFactor', fromPowerFactor);
powerFactor('toPowerFactor', toPowerFactor);
if (toPowerFactor <= fromPowerFactor) {
throw new RangeError(
`toPowerFactor (${toPowerFactor}) must be better than fromPowerFactor (${fromPowerFactor}); ` +
`correction improves a power factor, it does not worsen one.`);
}
const qBefore = kw * tanPhi(fromPowerFactor);
const qAfter = kw * tanPhi(toPowerFactor);
const sBefore = kw / fromPowerFactor;
const sAfter = kw / toPowerFactor;
return {
schema,
quantity: 'correction_kvar',
value: qBefore - qAfter,
unit: 'kVAr',
reactiveBeforeKvar: qBefore,
reactiveAfterKvar: qAfter,
apparentBeforeKva: sBefore,
apparentAfterKva: sAfter,
capacityReleasedKva: sBefore - sAfter,
capacityReleasedPercent: ((sBefore - sAfter) / sBefore) * 100,
from: { kw, fromPowerFactor, toPowerFactor },
basis:
`${(qBefore - qAfter).toFixed(1)} kVAr of correction moves ${kw} kW from ${fromPowerFactor} ` +
`to ${toPowerFactor}, taking apparent power from ${sBefore.toFixed(1)} kVA to ` +
`${sAfter.toFixed(1)} kVA and releasing ${(sBefore - sAfter).toFixed(1)} kVA — ` +
`${(((sBefore - sAfter) / sBefore) * 100).toFixed(1)}% of the site's demand on its ` +
`connection, for no reduction in consumption at all. Correcting to unity is usually the ` +
`wrong target: the last few percent costs disproportionately, and a fixed bank on a varying ` +
`load will over-correct at part load and may then be charged for exporting reactive power.`
};
}
/**
* What a released capacity is worth in headroom against a STATED agreed
* capacity — arithmetic on two figures the caller supplies.
*/
export function againstAgreedCapacity({ kw, powerFactor: pf, agreedKva }) {
const s = apparentPowerKva({ kw, powerFactor: pf });
positive('agreedKva', agreedKva);
return {
schema,
quantity: 'demand_against_agreed_capacity',
value: s.value / agreedKva,
unit: 'dimensionless',
percent: (s.value / agreedKva) * 100,
apparentKva: s.value,
agreedKva,
exceeds: s.value > agreedKva,
from: { kw, powerFactor: pf, agreedKva },
basis:
`${s.value.toFixed(1)} kVA against an agreed ${agreedKva} kVA is ` +
`${((s.value / agreedKva) * 100).toFixed(1)}%` +
(s.value > agreedKva
? `, which EXCEEDS the agreed capacity by ${(s.value - agreedKva).toFixed(1)} kVA.`
: `.`) +
` The agreed capacity is a commercial figure from a connection agreement, supplied by you. ` +
`This is a ratio of two stated numbers and not a connection assessment.`
};
}
export const NOT_COMPUTED = Object.freeze({
capacitorBankDesign:
'This does not design correction equipment. A real installation must be assessed for harmonic resonance against the supply impedance — a bank can amplify existing harmonic voltages badly enough to destroy itself and the plant around it — and that needs a harmonic study with the network operator\'s data.',
reactiveCharges:
'What excess reactive power costs depends on the network and the tariff, and tariffs change. No charge is calculated here.',
payback:
'Whether correction is worth installing is a commercial question with equipment cost, installation, maintenance and a tariff in it. This module sizes the duty only.',
varyingLoad:
'A single power factor describes one operating point. A real site varies, and a fixed bank sized for full load will over-correct at part load; staged or automatic correction is an equipment decision this arithmetic does not make.'
});Published Fault Level
A JavaScript module in Ventus Grid Engine that works with substations, using SHA-256. It formats number (`formatNumber`) and is built from the refuse step (`refuse`) and the record step (`record`).
electricalventus-grid-engine / engine/published-fault-level.js · lines 1–250 of 250 · Entry point · pattern quote (shared by 3 files)
- What it does
- It calculates substations. Defines refuse, record, quote, formatNumber.
- Why it exists in the grid workflow
- Domain terms in the code: substations.
- Downstream impact
- Used directly by 4 files: Build Graph (ventus-grid-engine, https://ventusltd.github.io/ventus-grid-engine/genome/); Published Fault Level Proof (ventus-grid-engine); Grid Engine — Published Fault Level Page (globalgrid2050, https://globalgrid2050.com/grid_engine/202609060236-published-fault-level/); Papers — Published Fault Level Page (globalgrid2050, https://globalgrid2050.com/papers/202609060045-published-fault-level/). Reached from 48 other entry points, including Grid Engine — Compute Against Charging Page (globalgrid2050, https://globalgrid2050.com/grid_engine/202609060324-compute-against-charging/); Grid Engine — Connection Cap Page (globalgrid2050, https://globalgrid2050.com/grid_engine/202609060212-connection-cap/); Grid Engine — Corridor Estimate Page (globalgrid2050, https://globalgrid2050.com/grid_engine/202609060237-corridor-estimate/).
- What it achieves
- This module is the estate's contract for carrying a fault-level figure on an open map.
- Why it matters
- Loaded by the page of the same name in GlobalGrid2050 at https://globalgrid2050.com/grid_engine/202609060236-published-fault-level/ and 1 other page. Also imported by Build Graph and Published Fault Level Proof.
- Application
- ventus-grid-engine · engine · JavaScript module
- Uses
- none found
- Used by
- named by URL in Build Graph (estate URL), imported by Published Fault Level Proof (import), linked from Grid Engine — Published Fault Level Page (link), linked from Papers — Published Fault Level Page (link)
- Produces
- schema, ETYS_METRICS, LTDS_METRICS, METRIC_LABELS, REFUSED_GENERIC_NAMES, CAVEAT, NOT_COMPUTED, NO_HEADROOM, record, quote
- Defines here
- refuse, record, quote, formatNumber
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- ventus-grid-engine@ad566356a44e006682e956483d569f31ddbb9630 engine/published-fault-level.js:1-250 · blob f97f5eb7967532aaa0caa9660b9ebc681e51d718 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: unknown · users: none · canonical: production_core
/**
* Module: published-fault-level
*
* PUBLISHED, DATED, NEVER CALCULATED.
*
* This module is the estate's contract for carrying a fault-level figure on
* an open map. It exists because a domain expert asked, on 2026-09-05,
* whether the Atlas had "maximum fault level currents for substations in the
* UK", and the honest answer was in three parts: it already carried a
* published transmission figure; it would never carry a computed one; and
* the number that binds anyone is the one the DNO produces at their point of
* connection and writes into the offer.
*
* WHAT A FAULT LEVEL IS, AND WHY ONE NUMBER IS NOT ONE.
* The short-circuit current at a busbar is set by the Thevenin equivalent
* impedance the network presents there, Z = R + jX. The magnitude sets the
* symmetrical current; the X/R ratio sets how quickly the DC offset decays,
* which is why the first-cycle peak ("make") and the RMS current at contact
* parting ("break") are different figures for the same bus, and why a
* three-phase and a single-phase-to-earth fault differ again. NESO's ETYS
* Appendix D publishes EIGHT separately named currents for this reason, and
* data-grid-gb's contract says the consumer "must not collapse them into a
* single generic fault level". This module enforces that: a record carries
* named metrics, and nothing here will ever call any of them "the fault
* level".
*
* WHY IT IS A NETWORK-STATE PROPERTY AND NOT A SUBSTATION ATTRIBUTE.
* Open a bus section and the impedance changes; connect another generator
* and it changes again; the transmission contribution upstream changes with
* demand case. A published figure is therefore a snapshot under a stated
* study basis on a stated date. This module refuses a record that does not
* carry that basis and that date, because a figure without them is not a
* measurement, it is a rumour.
*
* WHAT THIS MODULE DELIBERATELY DOES NOT DO.
* It has no function that computes a fault current. It has no function that
* computes headroom against a switchgear rating. Both are the tempting next
* step and both are wrong here: a computed current needs the DNO's model and
* running arrangement, which are not public; a headroom figure needs the
* asset's several ratings (make, break, short-time withstand, peak withstand)
* matched to the RIGHT published metric, and mismatching them is how a
* screening tool becomes a false connection assessment. The proof asserts
* these functions are ABSENT, so their absence is a tested property rather
* than an omission.
*
* The boundary, in the architect's words to a peer the same day: "we can
* definitely analyse private wires but the implementation is way beyond what
* AI can do as it needs engineering with electrical network impedance
* analysis". A published figure narrows a search. It never makes a decision.
*
* Depends on: nothing. Pure validation and formatting of caller-supplied,
* already-published data. No network, no DOM, no arithmetic on currents.
*
* Schema: ventus-grid-engine.published-fault-level.v1
*/
export const schema = 'ventus-grid-engine.published-fault-level.v1';
/* The eight currents NESO publishes in ETYS Appendix D, named exactly as
data-grid-gb normalises them (chatgpt/ingest_etys.py FAULT_COLUMNS). A
distribution publication may use a subset, or add the metrics DNOs commonly
publish in an LTDS; those must be DECLARED with a unit rather than smuggled
in under a generic name. */
export const ETYS_METRICS = Object.freeze([
'three_phase_initial_peak_current_ka',
'three_phase_rms_break_current_ka',
'three_phase_dc_break_current_ka',
'three_phase_peak_break_current_ka',
'single_phase_initial_peak_current_ka',
'single_phase_rms_break_current_ka',
'single_phase_dc_break_current_ka',
'single_phase_peak_break_current_ka'
]);
/* Metrics a DNO Long Term Development Statement commonly publishes. Kept
separate from the ETYS eight so a reader can see which publisher a name
belongs to; the two sets are never merged into one "fault level". */
export const LTDS_METRICS = Object.freeze([
'three_phase_fault_level_mva',
'three_phase_fault_current_ka',
'single_phase_earth_fault_current_ka',
'x_over_r_ratio'
]);
/* Every known metric with its unit and the plain-English label a card may
print. The label is the ONLY string this module will ever put next to a
number. */
export const METRIC_LABELS = Object.freeze({
three_phase_initial_peak_current_ka: { unit: 'kA', label: 'three-phase initial peak current' },
three_phase_rms_break_current_ka: { unit: 'kA', label: 'three-phase RMS break current' },
three_phase_dc_break_current_ka: { unit: 'kA', label: 'three-phase DC break current' },
three_phase_peak_break_current_ka: { unit: 'kA', label: 'three-phase peak break current' },
single_phase_initial_peak_current_ka: { unit: 'kA', label: 'single-phase initial peak current' },
single_phase_rms_break_current_ka: { unit: 'kA', label: 'single-phase RMS break current' },
single_phase_dc_break_current_ka: { unit: 'kA', label: 'single-phase DC break current' },
single_phase_peak_break_current_ka: { unit: 'kA', label: 'single-phase peak break current' },
three_phase_fault_level_mva: { unit: 'MVA', label: 'three-phase fault level (published as MVA)' },
three_phase_fault_current_ka: { unit: 'kA', label: 'three-phase fault current' },
single_phase_earth_fault_current_ka: { unit: 'kA', label: 'single-phase-to-earth fault current' },
x_over_r_ratio: { unit: '', label: 'X/R ratio' }
});
/* Names that are refused outright, because each is exactly the collapse the
contract forbids: a number with no statement of WHICH current it is. */
export const REFUSED_GENERIC_NAMES = Object.freeze([
'fault_level', 'fault_current', 'fault_level_ka', 'fault_level_mva',
'short_circuit_level', 'scl', 'fault', 'max_fault_level', 'maximum_fault_level'
]);
export const CAVEAT = 'A published figure under a stated study basis on a stated '
+ 'date. Not a connection assessment. The current that applies to a '
+ 'connection is produced by the network operator at the point of '
+ 'connection and stated in the connection offer.';
export const NOT_COMPUTED = 'No fault current is calculated here. The network '
+ 'impedance and running arrangement that determine it are the operator\'s '
+ 'model, not a public dataset.';
export const NO_HEADROOM = 'No headroom against a switchgear rating is '
+ 'calculated here. Switchgear carries several ratings (making, breaking, '
+ 'short-time withstand, peak withstand) and each must be matched to the '
+ 'right published metric by an engineer with the asset data.';
const ALLOWED_UNITS = new Set(['kA', 'MVA', '']);
const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
const SHA256_RE = /^[0-9a-f]{64}$/;
const URL_RE = /^https?:\/\/\S+$/;
function refuse(reason) {
return { ok: false, record: null, refused: reason };
}
/**
* Validate and freeze one published fault-level record.
*
* Accepts only what a publisher actually said, with enough provenance that a
* reader can go and read the same page: publisher, publication, the exact
* artefact URL and its SHA-256, the publication date, the study basis, the
* site and busbar the figure is for, and the metrics by exact name with a
* min, a max and a unit.
*
* Returns {ok:true, record} with the record frozen and carrying
* `computed:false`, or {ok:false, refused:<reason>}. A refusal is the answer,
* not an exception: a caller that cannot distinguish "no figure" from "a
* figure that failed validation" prints the wrong thing.
*/
export function record(input) {
if (!input || typeof input !== 'object') return refuse('no input');
const p = input.provenance;
if (!p || typeof p !== 'object') return refuse('no provenance');
for (const key of ['publisher', 'publication', 'source_url', 'sha256', 'published_date', 'study_basis']) {
if (typeof p[key] !== 'string' || p[key].trim() === '') return refuse('provenance.' + key + ' missing');
}
if (!URL_RE.test(p.source_url)) return refuse('provenance.source_url is not a URL');
if (!SHA256_RE.test(p.sha256)) return refuse('provenance.sha256 is not a 64-hex SHA-256');
if (!DATE_RE.test(p.published_date)) return refuse('provenance.published_date is not YYYY-MM-DD');
const site = input.site;
if (!site || typeof site !== 'object') return refuse('no site');
if (typeof site.name !== 'string' || site.name.trim() === '') return refuse('site.name missing');
if (!Number.isFinite(site.voltage_kv) || site.voltage_kv <= 0) return refuse('site.voltage_kv missing');
const busbar = typeof site.busbar === 'string' && site.busbar.trim() !== '' ? site.busbar : null;
const metrics = input.metrics;
if (!metrics || typeof metrics !== 'object' || Array.isArray(metrics)) return refuse('no metrics');
const names = Object.keys(metrics);
if (names.length === 0) return refuse('metrics is empty');
const out = {};
for (const name of names) {
const lower = String(name).toLowerCase();
if (REFUSED_GENERIC_NAMES.includes(lower)) {
return refuse('metric "' + name + '" is a generic name; state which current it is');
}
const m = metrics[name];
if (!m || typeof m !== 'object') return refuse('metric "' + name + '" is not an object');
const known = METRIC_LABELS[name];
const unit = known ? known.unit : m.unit;
if (!known) {
/* An undeclared metric is allowed ONLY if it declares its own unit and
label, so a reader is never shown a bare number. */
if (typeof m.unit !== 'string' || !ALLOWED_UNITS.has(m.unit)) return refuse('metric "' + name + '" is unknown and declares no allowed unit');
if (typeof m.label !== 'string' || m.label.trim() === '') return refuse('metric "' + name + '" is unknown and declares no label');
} else if (typeof m.unit === 'string' && m.unit !== known.unit) {
return refuse('metric "' + name + '" unit ' + m.unit + ' disagrees with ' + known.unit);
}
const min = Number(m.min);
const max = Number(m.max);
if (!Number.isFinite(min) || !Number.isFinite(max)) return refuse('metric "' + name + '" min/max not finite');
if (min < 0 || max < 0) return refuse('metric "' + name + '" is negative');
if (min > max) return refuse('metric "' + name + '" min exceeds max');
out[name] = Object.freeze({
min, max, unit,
label: known ? known.label : m.label,
declared: !known
});
}
const frozen = Object.freeze({
schema,
computed: false,
provenance: Object.freeze({
publisher: p.publisher,
publication: p.publication,
source_url: p.source_url,
sha256: p.sha256,
published_date: p.published_date,
study_basis: p.study_basis,
licence: typeof p.licence === 'string' ? p.licence : null
}),
site: Object.freeze({
name: site.name,
voltage_kv: site.voltage_kv,
busbar,
operator: typeof site.operator === 'string' ? site.operator : null
}),
metrics: Object.freeze(out),
caveat: CAVEAT
});
return { ok: true, record: frozen, refused: null };
}
/**
* The one line a card may print for ONE named metric of a record.
*
* Always the label, the range, the unit, the publisher and the date. Never
* the words "fault level" on their own. A caller that wants a different
* metric asks for it by name; there is no "default" metric, because a
* default is a silent choice a reader cannot see.
*/
export function quote(rec, metricName) {
if (!rec || rec.schema !== schema) return null;
const m = rec.metrics[metricName];
if (!m) return null;
const range = m.min === m.max
? formatNumber(m.min)
: formatNumber(m.min) + '–' + formatNumber(m.max);
const unit = m.unit ? ' ' + m.unit : '';
const where = rec.site.busbar ? rec.site.name + ' ' + rec.site.busbar : rec.site.name;
return m.label + ' ' + range + unit
+ ' · ' + where + ' ' + rec.site.voltage_kv + ' kV'
+ ' · ' + rec.provenance.publisher + ', ' + rec.provenance.publication
+ ' · ' + rec.provenance.study_basis
+ ' · published ' + rec.provenance.published_date;
}
function formatNumber(n) {
return Number.isInteger(n) ? String(n) : n.toFixed(2).replace(/\.?0+$/, '');
}