In this section
- Compute Observer transform · ventus-grid-engine / engine/compute-observer.js lines 1–103
- Compute Presentation transform · ventus-grid-engine / engine/compute-presentation.js lines 1–18
- Connection Capacity energy-data · ventus-grid-engine / engine/connection-capacity.js lines 1–278
- Corridor Estimate render · ventus-grid-engine / engine/corridor-estimate.js lines 1–84
- Current from Power electrical · ventus-grid-engine / engine/current-from-power.js lines 1–144
Compute Observer
A JavaScript module in Ventus Grid Engine that works with same location (`sameLocation`) and same entity (`sameEntity`).
transformventus-grid-engine / engine/compute-observer.js · lines 1–103 of 103 · Entry point · pattern createComputeObserver (shared by 7 files)
- What it does
- It calculates its inputs. Defines 8 functions or classes, including copy, finite, located, sameLocation, sameEntity.
- Why it exists in the grid workflow
- README: "`engine/compute-observer.js` provides browser-neutral computation receipts for the Test Code detector."
- Downstream impact
- Used directly by 1 file: Compute Observer Proof (ventus-grid-engine).
- What it achieves
- It is built from the copy step (`copy`), the finite step (`finite`) and the located step (`located`). Actual-computation receipts, shared by Node and browsers.
- Why it matters
- Imported by Compute Observer Proof.
- Application
- ventus-grid-engine · engine · JavaScript module
- Uses
- V9 Geodesy (import)
- Used by
- imported by Compute Observer Proof (import)
- Produces
- schema, createComputeObserver
- Defines here
- copy, finite, located, sameLocation, sameEntity, createComputeObserver, publish, get
- 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/compute-observer.js:1-103 · blob 47b983e9df8a268764619486fbadb9c63b4e3de8 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: unknown · users: none · canonical: production_core
/** Actual-computation receipts, shared by Node and browsers. No DOM or network. */
import { distanceKm } from './v9-geodesy.js';
export const schema = 'ventus.grid-compute-receipt.v1';
const copy = value => JSON.parse(JSON.stringify(value));
const finite = value => typeof value === 'number' && Number.isFinite(value);
const located = point => point && finite(point.lon) && finite(point.lat)
&& Math.abs(point.lon) <= 180 && Math.abs(point.lat) <= 90;
const sameLocation = (a, b) => located(a) && located(b) && a.lon === b.lon && a.lat === b.lat;
const sameEntity = (a, b) => a && b && a.kind === b.kind && String(a.id) === String(b.id);
/**
* Create one observer per selection surface, not one per project. Every request
* invalidates the previous selection for assessment, including repeated IDs.
* Receipts are evidence about the supplied callback, not proof that a renderer
* used this module. Attach run() at the real calculation call site.
*/
export function createComputeObserver({ onEvent = () => {}, now = () => Date.now() } = {}) {
const attempts = new Map();
let sequence = 0;
let latest = null;
const publish = (attempt, status, extra = {}) => {
Object.assign(attempt, extra, { status, sequence: ++sequence, updated_at_ms: now() });
attempt.events.push({ status, sequence: attempt.sequence, at_ms: attempt.updated_at_ms });
// A broken logging consumer must never break the grid calculation itself.
try { onEvent(copy(attempt)); } catch { /* receipt remains queryable */ }
return copy(attempt);
};
const get = id => {
const attempt = attempts.get(id);
if (!attempt) throw new Error('Unknown computation attempt: ' + id);
return attempt;
};
return {
request({ entity, location = null, operation = 'nearest-grid', dataset = null }) {
if (!entity || typeof entity.kind !== 'string' || !entity.kind.trim()
|| entity.id == null || !String(entity.id).trim()) {
throw new TypeError('A computation request requires an entity kind and ID');
}
const id = 'compute-' + (sequence + 1);
const attempt = {
schema, id, entity: { kind: entity.kind, id: String(entity.id) },
location: located(location) ? { lon: location.lon, lat: location.lat } : null,
operation, dataset, requested_at_ms: now(), events: []
};
attempts.set(id, attempt);
latest = id;
publish(attempt, 'requested');
return id;
},
unsupported(id, reason) {
const attempt = get(id);
if (attempt.status !== 'requested') throw new Error('Attempt already invoked or terminal');
return publish(attempt, 'unsupported', { reason: String(reason || 'Unsupported input') });
},
async run(id, compute) {
const attempt = get(id);
if (attempt.status !== 'requested') throw new Error('Attempt already invoked or terminal');
if (!attempt.location) return publish(attempt, 'unsupported', { reason: 'No valid project location' });
if (typeof compute !== 'function') return publish(attempt, 'failed', { reason: 'No computation callback' });
publish(attempt, 'started');
try {
const result = await compute(copy(attempt));
if (!sameLocation(result?.origin, attempt.location)) throw new Error('Result origin does not match this request');
if (!sameEntity(result?.entity, attempt.entity)) throw new Error('Result entity does not match this request');
if (!Array.isArray(result.measurements)) throw new Error('Computation returned no measurements array');
if (result.measurements.length === 0) {
if (result.search_completed !== true || !Number.isInteger(result.scanned_count) || result.scanned_count < 0) {
throw new Error('Empty result lacks completed-search and scanned-count evidence');
}
return publish(attempt, 'completed_empty', { measurements: [],
summary: { measured_count: 0, scanned_count: result.scanned_count, nearest_km: null } });
}
const measurements = result.measurements.map(row => {
if (!row || row.node_id == null || !String(row.node_id).trim()
|| !located(row) || !finite(row.km) || row.km < 0) {
throw new Error('Computation returned an invalid grid measurement');
}
const expected = distanceKm(attempt.location.lon, attempt.location.lat, row.lon, row.lat);
// Receipts carry unrounded values from the shared geodesy, not UI text.
if (Math.abs(expected - row.km) > Math.max(1e-6, expected * 1e-9)) {
throw new Error('Grid distance does not match the request and measured node');
}
return { node_id: String(row.node_id), lon: row.lon, lat: row.lat, km: row.km };
});
return publish(attempt, 'completed', { measurements,
summary: { measured_count: measurements.length, nearest_km: Math.min(...measurements.map(row => row.km)) } });
} catch (error) {
return publish(attempt, 'failed', { reason: String(error?.message || error) });
}
},
snapshot(id = latest) { return id == null ? null : copy(get(id)); },
assess(id, expected) {
if (!attempts.has(id)) return { passed: false, reason: 'never-requested' };
const attempt = get(id);
if (id !== latest) return { passed: false, reason: 'stale-attempt' };
if (!sameEntity(attempt.entity, expected?.entity) || !sameLocation(attempt.location, expected?.location)) {
return { passed: false, reason: 'selection-mismatch' };
}
return { passed: attempt.status === 'completed', reason: attempt.status };
}
};
}Compute Presentation
A JavaScript module in Ventus Grid Engine that works with substations. It describes compute receipt (`describeComputeReceipt`).
transformventus-grid-engine / engine/compute-presentation.js · lines 1–18 of 18 · Entry point · pattern describeComputeReceipt (shared by 6 files)
- What it does
- It calculates substations. Defines describeComputeReceipt.
- Why it exists in the grid workflow
- Domain terms in the code: substations.
- Downstream impact
- Used directly by 1 file: Browser Observer Proof (ventus-grid-engine).
- What it achieves
- Honest UI projection of computation receipts.
- Why it matters
- Imported by Browser Observer Proof.
- Application
- ventus-grid-engine · engine · JavaScript module
- Uses
- none found
- Used by
- imported by Browser Observer Proof (import), mentioned in Standalone (comment link)
- Produces
- describeComputeReceipt
- Defines here
- describeComputeReceipt
- 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/compute-presentation.js:1-18 · blob 252afc4ea76a3a24b4745da746496241c0d8be3e · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: unknown · users: none · canonical: production_core
/** Honest UI projection of computation receipts. No inference from a URL. */
export function describeComputeReceipt(receipt) {
const status = receipt?.status || 'not_requested';
const summary = receipt?.summary;
const nearest = summary?.nearest_km;
const labels = {
not_requested: 'Grid calculation not requested', requested: 'Grid calculation queued',
started: 'Calculating nearest mapped substations', completed_empty: 'Search completed: no mapped substations returned',
unsupported: 'Grid calculation unavailable', failed: 'Grid calculation failed',
};
if (status === 'completed' && Number.isFinite(nearest) && nearest >= 0) {
return { status, text: `Nearest mapped substation: ${nearest.toFixed(2)} km`,
distance_km: nearest, unit: 'km', scope: 'Geometric screening only; not an electrical connection, capacity or offer.' };
}
return { status, text: labels[status] || 'Grid calculation result unavailable',
reason: receipt?.reason || null, distance_km: null, unit: null,
scope: 'Geometric screening only; not an electrical connection, capacity or offer.' };
}Connection Capacity
A JavaScript module in Ventus Grid Engine that works with clipped energy (`clippedEnergy`) (units: kW, kWh, MW).
energy-dataventus-grid-engine / engine/connection-capacity.js · lines 1–278 of 278 · pattern ratio (shared by 8 files)
- What it does
- It calculates its inputs. Defines 7 functions or classes, including positive, ratio, profileOf, exceedance, batteryForPeakShaving.
- Downstream impact
- Used directly by 6 files: Grid Engine — Solar Battery Energy Storage System (BESS) Export Page (globalgrid2050, https://globalgrid2050.com/grid_engine/202609060217-solar-bess-export/); Grid Engine — Solar Farm Page (globalgrid2050, https://globalgrid2050.com/grid_engine/202609060318-solar-farm/); Build Graph (ventus-grid-engine, https://ventusltd.github.io/ventus-grid-engine/genome/); Connection Capacity Proof (ventus-grid-engine); and 2 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 positive step (`positive`), the ratio step (`ratio`) and the profile of helper (`profileOf`). APPLIED ENGINEERING for the people who actually have to build something: a developer, an EPC, or a heavy energy user with an agreed capacity at a connection and a load or generation profile that does not fit inside it. Its code works with 12 MW and 30 MVA.
- Why it matters
- Loaded by the Solar Battery Energy Storage System (BESS) Export page in GlobalGrid2050 at https://globalgrid2050.com/grid_engine/202609060217-solar-bess-export/ and 3 other pages. Also imported by Build Graph and Connection Capacity Proof.
- Application
- ventus-grid-engine · engine · JavaScript module
- VEDIC
- SIZE PEAK SHAVING BATTERY (GG2050-VEDIC-000071): Ventus Grid Engine · Energy and power calculation. profileKw, capKw, intervalHours, roundTripEfficiency, depthOfDischarge → Power, usable and installed energy, duration and charge energy.
- VEDIC
- MEASURE EXPORT CLIPPING (GG2050-VEDIC-000052): Ventus Grid Engine · Energy and power calculation. generation_samples_kw, export_cap_kw, hours_per_sample → potential_delivered_and_clipped_energy_kwh_summary
- VEDIC
- BALANCE GRID EXCHANGE (GG2050-VEDIC-000053): Ventus Grid Engine · Energy and power calculation. load_samples_kw, generation_samples_kw, import_cap_kw, export_cap_kw, hours_per_sample → import_export_peak_kw_energy_kwh_and_breach_summary
- Uses
- none found
- Used by
- linked from Grid Engine — Solar Battery Energy Storage System (BESS) Export Page (link), linked from Grid Engine — Solar Farm Page (link), named by URL in Build Graph (estate URL), imported by Connection Capacity Proof (import), linked from Grid Engine — Connection Cap Page (link), linked from Grid Engine — EV Depot Page (link), mentioned in Standalone (comment link)
- Produces
- schema, exceedance, batteryForPeakShaving, clippedEnergy, netAtConnection, NOT_COMPUTED
- Defines here
- positive, ratio, profileOf, exceedance, batteryForPeakShaving, clippedEnergy, netAtConnection
- 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/connection-capacity.js:1-278 · blob 8ef22153b2d660bbfd942ac7b4e819d69061a187 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: unknown · users: none · canonical: production_core
/**
* Module: connection-capacity
*
* APPLIED ENGINEERING for the people who actually have to build something: a
* developer, an EPC, or a heavy energy user with an agreed capacity at a
* connection and a load or generation profile that does not fit inside it.
*
* THE QUESTION THIS ANSWERS.
* "My site is capped at 30 MVA. My demand peaks at 42. How much battery, in MW
* and in MWh, keeps me inside the cap — and how often would it have to work?"
* That is a real, daily, commercially decisive calculation, and it is ordinary
* arithmetic over a profile once the cap is stated. It is offered here in full.
*
* WHY THE CAP IS AN INPUT AND NEVER AN INFERENCE.
* An agreed import or export capacity is a commercial parameter written into a
* connection agreement. It is not a physical property of the network and it
* cannot be derived from a map, a rating, or a fault level. So every function
* here takes the cap from the caller. Nothing in this module will ever tell you
* what cap you could get — that is an application and an offer.
*
* WHY A PROFILE AND NOT A PEAK.
* Sizing a battery from the peak alone gives you the POWER and tells you
* nothing about the ENERGY. A site that exceeds its cap by 12 MW for six
* minutes needs a very different asset from one that exceeds it by 12 MW for
* four hours, and the difference is a factor of forty in cost. The energy comes
* from the area above the cap, which needs the shape. These functions therefore
* take an interval profile and an interval length, and report both power and
* energy, plus how many intervals were involved.
*
* ROUND-TRIP EFFICIENCY IS APPLIED WHERE IT ACTUALLY BITES.
* A battery discharging E kWh to the site must have stored E / eta kWh, so the
* charging requirement — and the grid energy bought to do it — is larger than
* the energy delivered. Sizing the usable energy without dividing by efficiency
* under-sizes the asset. Depth of discharge is applied on top, because an
* installed pack is never fully usable.
*
* SOLAR CLIPPING IS THE SAME ARITHMETIC POINTING THE OTHER WAY.
* A DC array behind a smaller AC connection loses the area above the cap, every
* time. That loss is often acceptable and sometimes deliberate — oversizing DC
* against a constrained export limit is a normal design choice — but it has to
* be quantified rather than assumed away.
*
* WHAT THIS MODULE REFUSES.
* It will not tell you what connection capacity is available, what it would
* cost, whether an offer would be made, or what the network can accept. Those
* are the operator's answers. It also will not optimise a dispatch: the
* shaving here is the simple, physically necessary one — discharge exactly the
* excess — which is the right basis for SIZING. A revenue-stacking dispatch is
* a different problem with commercial inputs this module does not have.
*
* Schema: ventus-grid-engine.connection-capacity.v1
*/
export const schema = 'ventus-grid-engine.connection-capacity.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 ratio(name, v) {
positive(name, v);
if (v > 1) throw new RangeError(
`${name} must be a fraction in (0, 1], received ${v}. A percentage such as 88 must be passed as 0.88.`);
return v;
}
function profileOf(name, p) {
if (!Array.isArray(p) || p.length === 0) {
throw new TypeError(`${name} must be a non-empty array of interval values`);
}
p.forEach((v, i) => {
if (typeof v !== 'number' || !Number.isFinite(v)) {
throw new TypeError(`${name}[${i}] must be a finite number, received ${typeof v}`);
}
if (v < 0) throw new RangeError(`${name}[${i}] must not be negative, received ${v}`);
});
return p;
}
/**
* How far, how often and how much a profile exceeds a stated cap.
*
* The foundation of everything below: peak excess sets the POWER, the area
* above the cap sets the ENERGY, and the interval count says how often it
* matters.
*/
export function exceedance({ profileKw, capKw, intervalHours }) {
profileOf('profileKw', profileKw);
positive('capKw', capKw);
positive('intervalHours', intervalHours);
if (intervalHours > 24) throw new RangeError(`intervalHours must be at most 24, received ${intervalHours}`);
let peakExcess = 0, energyKwh = 0, intervals = 0, peakKw = 0, totalKwh = 0;
for (const v of profileKw) {
totalKwh += v * intervalHours;
if (v > peakKw) peakKw = v;
const over = v - capKw;
if (over > 0) {
intervals += 1;
energyKwh += over * intervalHours;
if (over > peakExcess) peakExcess = over;
}
}
const spanHours = profileKw.length * intervalHours;
return {
schema,
quantity: 'exceedance_above_cap',
peakKw,
capKw,
peakExcessKw: peakExcess,
energyAboveCapKwh: energyKwh,
intervalsAboveCap: intervals,
intervalCount: profileKw.length,
fractionOfTimeAboveCap: intervals / profileKw.length,
spanHours,
siteEnergyKwh: totalKwh,
siteLoadFactor: totalKwh / (peakKw * spanHours),
withinCap: peakExcess === 0,
basis: peakExcess === 0
? `The profile peaks at ${peakKw} kW and never exceeds the ${capKw} kW cap. No shaving is required.`
: `The profile peaks at ${peakKw} kW against a ${capKw} kW cap: a peak excess of ` +
`${peakExcess} kW, exceeded in ${intervals} of ${profileKw.length} intervals ` +
`(${((intervals / profileKw.length) * 100).toFixed(1)}% of the time), with ` +
`${energyKwh.toFixed(1)} kWh above the cap across ${spanHours} hours. The peak excess ` +
`sizes the POWER; the energy above the cap sizes the STORE. Sizing from the peak alone ` +
`says nothing about the second, and the two can differ by a factor of forty in cost.`
};
}
/**
* The battery that keeps a profile inside its cap.
*
* Power from the peak excess. Usable energy from the area above the cap.
* Installed energy from usable energy after round-trip efficiency and depth of
* discharge — both of which make the asset BIGGER, never smaller.
*/
export function batteryForPeakShaving({ profileKw, capKw, intervalHours, roundTripEfficiency, depthOfDischarge }) {
const ex = exceedance({ profileKw, capKw, intervalHours });
ratio('roundTripEfficiency', roundTripEfficiency);
ratio('depthOfDischarge', depthOfDischarge);
const usableKwh = ex.energyAboveCapKwh;
const storedKwh = usableKwh / roundTripEfficiency;
const installedKwh = storedKwh / depthOfDischarge;
const powerKw = ex.peakExcessKw;
return {
schema,
quantity: 'battery_for_peak_shaving',
powerKw,
usableEnergyKwh: usableKwh,
installedEnergyKwh: installedKwh,
durationHours: powerKw > 0 ? installedKwh / powerKw : 0,
chargeEnergyRequiredKwh: storedKwh,
cyclesImplied: ex.intervalsAboveCap > 0 ? 1 : 0,
from: {
capKw, roundTripEfficiency, depthOfDischarge,
peakExcessKw: ex.peakExcessKw, energyAboveCapKwh: ex.energyAboveCapKwh,
intervalsAboveCap: ex.intervalsAboveCap
},
basis: ex.withinCap
? `The profile never exceeds the ${capKw} kW cap, so no battery is required for shaving. ` +
`A battery may still be worth having for other reasons; this function does not assess them.`
: `To hold the site inside ${capKw} kW: ${powerKw} kW of power, set by the worst interval, ` +
`and ${usableKwh.toFixed(1)} kWh delivered, set by the area above the cap. Delivering ` +
`that requires ${storedKwh.toFixed(1)} kWh stored at ${roundTripEfficiency} round-trip, ` +
`and an installed ${installedKwh.toFixed(1)} kWh at ${depthOfDischarge} depth of ` +
`discharge — about a ${(installedKwh / powerKw).toFixed(2)}-hour asset. Efficiency and ` +
`depth of discharge only ever make it bigger. This sizes for the simple physical duty ` +
`of discharging exactly the excess; it is not an optimised revenue dispatch.`
};
}
/**
* Energy lost when generation behind a connection exceeds its export cap.
*
* Oversizing DC against a constrained AC connection is a normal design choice.
* It is only a good one when the loss is quantified.
*/
export function clippedEnergy({ generationKw, exportCapKw, intervalHours }) {
profileOf('generationKw', generationKw);
positive('exportCapKw', exportCapKw);
positive('intervalHours', intervalHours);
let clippedKwh = 0, deliveredKwh = 0, intervals = 0, peakKw = 0;
for (const v of generationKw) {
if (v > peakKw) peakKw = v;
const over = v - exportCapKw;
if (over > 0) { clippedKwh += over * intervalHours; intervals += 1; deliveredKwh += exportCapKw * intervalHours; }
else deliveredKwh += v * intervalHours;
}
const potentialKwh = clippedKwh + deliveredKwh;
return {
schema,
quantity: 'clipped_energy',
clippedKwh,
deliveredKwh,
potentialKwh,
clippedFraction: potentialKwh > 0 ? clippedKwh / potentialKwh : 0,
intervalsClipped: intervals,
peakGenerationKw: peakKw,
exportCapKw,
basis: clippedKwh === 0
? `Generation peaks at ${peakKw} kW and never exceeds the ${exportCapKw} kW export cap. Nothing is clipped.`
: `Generation peaks at ${peakKw} kW against a ${exportCapKw} kW export cap. ` +
`${clippedKwh.toFixed(1)} kWh is clipped across ${intervals} intervals — ` +
`${((clippedKwh / potentialKwh) * 100).toFixed(2)}% of what the array would otherwise ` +
`have produced. Oversizing behind a constrained connection is a legitimate design ` +
`choice; it is only a good one once this number is known rather than assumed away.`
};
}
/**
* Net position at the connection point for a site with both load and
* generation, against separate import and export caps.
*/
export function netAtConnection({ loadKw, generationKw, importCapKw, exportCapKw, intervalHours }) {
profileOf('loadKw', loadKw);
profileOf('generationKw', generationKw);
if (loadKw.length !== generationKw.length) {
throw new RangeError(
`loadKw has ${loadKw.length} intervals and generationKw has ${generationKw.length}; ` +
`they must describe the same period at the same resolution.`);
}
positive('importCapKw', importCapKw);
positive('exportCapKw', exportCapKw);
positive('intervalHours', intervalHours);
let peakImport = 0, peakExport = 0, importKwh = 0, exportKwh = 0;
let importBreaches = 0, exportBreaches = 0;
for (let i = 0; i < loadKw.length; i++) {
const net = loadKw[i] - generationKw[i];
if (net >= 0) {
importKwh += net * intervalHours;
if (net > peakImport) peakImport = net;
if (net > importCapKw) importBreaches += 1;
} else {
const exp = -net;
exportKwh += exp * intervalHours;
if (exp > peakExport) peakExport = exp;
if (exp > exportCapKw) exportBreaches += 1;
}
}
return {
schema,
quantity: 'net_position_at_connection',
peakImportKw: peakImport,
peakExportKw: peakExport,
importKwh,
exportKwh,
importCapKw,
exportCapKw,
importBreaches,
exportBreaches,
withinBothCaps: importBreaches === 0 && exportBreaches === 0,
basis:
`Net of load against generation, interval by interval: peak import ${peakImport.toFixed(1)} kW ` +
`against a ${importCapKw} kW cap (${importBreaches} breaches), peak export ` +
`${peakExport.toFixed(1)} kW against a ${exportCapKw} kW cap (${exportBreaches} breaches). ` +
`Import and export caps are separate commercial parameters and are frequently different ` +
`numbers; netting them into one figure hides a breach in either direction.`
};
}
export const NOT_COMPUTED = Object.freeze({
availableConnectionCapacity:
'What capacity you could be offered is the network operator\'s answer, from an application. It is a commercial parameter, not a physical property, and nothing on a map implies it.',
connectionCost:
'Reinforcement cost depends on the works the operator specifies and on cost apportionment rules. It cannot be derived from a demand profile.',
optimisedDispatch:
'The shaving here is the simple physical duty — discharge exactly the excess — which is the correct basis for SIZING. Revenue-stacked dispatch across markets is a different problem needing commercial inputs this module does not have.',
degradationAndWarranty:
'Cycle life, calendar ageing and warranty terms belong to the cell supplier and the contract. This module sizes for the duty; it does not tell you what that duty costs the asset.'
});Corridor Estimate
A JavaScript module in Ventus Grid Engine covering cables and overhead lines (OHL), using haversine. It is built from the for cable helper (`forCable`).
renderventus-grid-engine / engine/corridor-estimate.js · lines 1–84 of 84 · Entry point · pattern forCable (shared by 10 files)
- What it does
- Defines forCable. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage hv_procurement (path word 'estimate'): HV materials procurement, which Ventus Ltd states is within its commercial execution boundary. Domain terms in the code: cables, overhead lines (OHL).
- Downstream impact
- Used directly by 5 files: Route Obstacles Proof (ventus-grid-engine); Build Graph (ventus-grid-engine, https://ventusltd.github.io/ventus-grid-engine/genome/); Corridor Estimate Proof (ventus-grid-engine); Grid Engine — Corridor Estimate Page (globalgrid2050, https://globalgrid2050.com/grid_engine/202609060237-corridor-estimate/); and 1 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
- PROMOTED from `sources/v9-extracts/corridor-estimate.mjs` (itself extracted verbatim from `gridatlas/atlas/modules/202609030205-corridor-estimate.js`).
- Why it matters
- Loaded by the page of the same name in GlobalGrid2050 at https://globalgrid2050.com/grid_engine/202609060237-corridor-estimate/ and 1 other page. Also imported by Route Obstacles Proof, Build Graph and Corridor Estimate Proof.
- Application
- ventus-grid-engine · engine · JavaScript module
- Uses
- none found
- Used by
- imported by Route Obstacles Proof (import), named by URL in Build Graph (estate URL), imported by Corridor Estimate Proof (import), linked from Grid Engine — Corridor Estimate Page (link), named by URL in Ventus Grid Engine — Genome Page (estate URL)
- Produces
- CABLE_FACTOR, OHL_FACTOR, MINIMUM_KM, BASIS, CAVEAT, NOT_FOR_OVERHEAD, forCable, not_an_assessment, schema
- Defines here
- forCable
- 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/corridor-estimate.js:1-84 · blob 6951c9652cdb7ab2a3b3e5c29450f0c97adc5395 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: hv_procurement · users: EPC_contractor, procurement_buyer · canonical: production_core
/**
* Module: corridor-estimate
*
* PROMOTED from sources/v9-extracts/corridor-estimate.mjs (itself
* extracted verbatim from gridatlas/atlas/modules/202609030205-corridor-estimate.js).
*
* A straight line is not a route: an empirically calibrated multiplier
* (CABLE_FACTOR = 1.245) turning a great-circle distance into an
* indicative highway-corridor screening estimate for CABLE circuits only,
* calibrated against 95 published GB transmission cable circuits spanning
* 59 distinct site pairs (median absolute error 8.45%, 73% within 15%).
* Refuses to estimate below 1 km (MINIMUM_KM), where centroid resolution
* dominates the geometry. Deliberately has no forOverhead(): OHL_FACTOR
* (1.13) is published only so a reader can see why the cable factor is
* the wrong model for an overhead-line question.
*
* Depends on: nothing. Pure scalar arithmetic on a caller-supplied
* straight-line km (the caller is expected to have produced that km via
* v9-geodesy.js distanceKm or geo-core.js haversine).
*
* CHANGED FROM THE SOURCE: the IIFE and `window.__GRIDATLAS_MODULES__`
* registration are removed. `forCable()` is otherwise unchanged — verified
* verbatim against gridatlas/atlas/modules/202609030205-corridor-estimate.js
* at HEAD 64268fd06a0da54ddffbcdaaaee382e314e829f7 (see
* sources/provenance.json).
*/
export const CABLE_FACTOR = 1.245;
export const OHL_FACTOR = 1.13;
export const MINIMUM_KM = 1;
export const BASIS = Object.freeze({
factor: CABLE_FACTOR,
median_absolute_error_pct: 8.45,
within_15_pct: 73,
circuits: 95,
distinct_site_pairs: 59,
source: 'published built lengths of GB transmission cable circuits',
sample_note: 'parallel circuits between the same two sites duplicate the '
+ 'geometry, so the sample is 59 distinct site pairs and not 95 circuits',
minimum_separation_km: MINIMUM_KM,
below_minimum: 'under about a kilometre the site-centroid resolution '
+ 'dominates: median published length 0.59 km against a median error of '
+ '52.5%, so a straight line between centroids is not measuring route '
+ 'factor and no estimate is offered'
});
export const CAVEAT = 'Indicative highway-corridor screening only. Not a connection '
+ 'offer, not a constructability assessment and not a consenting design.';
export const NOT_FOR_OVERHEAD = 'Calibrated on cable circuits, which follow the '
+ 'highway network. Overhead line crosses open country and measures 1.13; '
+ 'this factor is not applied to an overhead-line question.';
/**
* The corridor estimate for a CABLE route of `km` straight-line distance.
* @returns null when there is nothing honest to say — no distance, or a
* separation short enough that the straight line is not measuring
* route factor. Null is the answer, not zero.
*/
export function forCable(km) {
const straight = Number(km);
if (!Number.isFinite(straight) || straight <= 0) return null;
if (straight < MINIMUM_KM) {
return { km: null, factor: CABLE_FACTOR, straight_km: straight,
withheld: BASIS.below_minimum };
}
return {
km: straight * CABLE_FACTOR,
factor: CABLE_FACTOR,
straight_km: straight,
withheld: null
};
}
/* Deliberately no forOverhead(). A module that offered one would be used,
and OHL_FACTOR above is published here so a reader can see WHY the
cable factor is not the answer to that question — not so that this
module can start answering it. */
export const not_an_assessment = 'An estimated corridor length says nothing about '
+ 'whether a connection is available, consentable or affordable.';
export const schema = 'gridatlas.module.corridor-estimate.v1';Current from Power
A JavaScript module in Ventus Grid Engine that works with cables. It is built from the positive step (`positive`), the phases of helper (`phasesOf`) and the current a helper (`currentA`).
electricalventus-grid-engine / engine/current-from-power.js · lines 1–144 of 144 · Not reached from any entry point (candidate for review) · pattern phasesOf (shared by 2 files)
- What it does
- It calculates cables. Defines positive, phasesOf, currentA, currentFromMvaAtKv.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (voltage levels 400kV, 132kV (all 132kV or above)): 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: cables, 400kV, 132kV.
- Inputs & outputs
- Voltage levels named: 400kV, 132kV.
- Downstream impact
- Used directly by 1 file: Current from Power Proof (ventus-grid-engine).
- What it achieves
- The amps implied by a power and a voltage. Its code works with 132 kV and 400 kV.
- Why it matters
- Imported by Current from Power Proof.
- Application
- ventus-grid-engine · engine · JavaScript module
- VEDIC
- CONVERT APPARENT POWER TO CURRENT (GG2050-VEDIC-000069): Ventus Grid Engine · Energy and power calculation. apparent_power_va, voltage_v, single_or_three_phase_optional → current_in_amperes_result
- Uses
- none found
- Used by
- imported by Current from Power Proof (import), mentioned in Standalone (comment link)
- Produces
- schema, CURRENT_PHASE_FACTOR, NOT_COMPUTED, NOT_A_HEADROOM, currentA, currentFromMvaAtKv
- Defines here
- positive, phasesOf, currentA, currentFromMvaAtKv
- 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/current-from-power.js:1-144 · blob 78dc747eff3c8e5d8b756fac1652674dc7c3c320 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
/**
* Module: current-from-power
*
* APPLIED ENGINEERING. The amps implied by a power and a voltage.
*
* WHY THIS FILE EXISTS AT ALL.
* Every published network figure in this estate is a power: a circuit is
* rated in MVA, a demand is quoted in MW, a firm capacity is an MVA number.
* Every cable calculation in this estate takes a current: voltage-drop.js
* asks for `currentA` and will not proceed without it. Nothing joined the
* two. A reader could hold a 1,200 MVA circuit rating in one hand and a
* voltage-drop calculator in the other and have no honest way to connect
* them, so the chain from a published rating to a cable answer stopped in
* the middle. This module is that one step and nothing more.
*
* THE ARITHMETIC.
*
* three phase: I = S / (sqrt(3) x V_line)
* single phase: I = S / V
*
* S is apparent power in volt-amperes and V is the line-to-line voltage for
* a three-phase circuit, the line-to-neutral voltage for a single-phase one.
*
* WHY THE THREE-PHASE FACTOR IS NOT THE ONE IN voltage-drop.js.
* That file exports PHASE_FACTOR = { three: sqrt(3), single: 2 } and it is
* tempting to import it here. It is the wrong constant and importing it
* would be a silent factor-of-two error on every single-phase answer. In a
* voltage drop the single-phase factor is 2 because the current goes out
* along one conductor and back along another and loses volts in both. In a
* current calculation there is one current, not two conductors' worth of
* impedance, so the single-phase factor is 1. The three-phase factor is
* sqrt(3) in both, for the same reason in both, which is exactly what makes
* the mistake easy to make. The two constants are therefore declared
* separately and this paragraph is why.
*
* WHAT THIS MODULE REFUSES.
* It will not tell you what a circuit is carrying. A rating is what a
* circuit is rated to carry; the current that flows is set by the load, and
* no amount of arithmetic on a nameplate discovers it. It will not choose a
* voltage: a site with 400 kV and 132 kV busbars has two answers and only
* the caller knows which circuit is meant. It carries no derating: ambient
* temperature, grouping, burial depth, soil resistivity and season all move
* the number a real conductor may carry, and none of them is here. And it
* will not accept a power factor to convert MW into MVA, because that is
* power-factor.js's question and answering it twice in two files is how the
* two answers begin to disagree.
*
* Schema: ventus-grid-engine.current-from-power.v1
*/
export const schema = 'ventus-grid-engine.current-from-power.v1';
/* The divisor between apparent power and current. NOT the same map as
voltage-drop.js PHASE_FACTOR; see the header. */
export const CURRENT_PHASE_FACTOR = Object.freeze({
three: Math.sqrt(3),
single: 1
});
export const NOT_COMPUTED = Object.freeze({
actualCurrent:
'This is the current implied by a stated power at a stated voltage. It '
+ 'is not what the circuit is carrying. Load sets the flow; a nameplate '
+ 'does not.',
derating:
'No ambient temperature, grouping factor, burial depth, soil thermal '
+ 'resistivity or seasonal rating is applied. The amps here are the '
+ 'arithmetic of the stated power, not a thermal limit for a real '
+ 'conductor in a real trench.',
voltageChoice:
'A site publishes several voltages. This module never chooses one. The '
+ 'caller states the voltage of the circuit being asked about.',
powerFactor:
'Converting MW to MVA needs a power factor and that is power-factor.js. '
+ 'This module takes apparent power only, so the two files cannot '
+ 'disagree about the same number.'
});
export const NOT_A_HEADROOM =
'The current implied by a rating is not spare capacity. What is free on a '
+ 'circuit is the rating minus what is already flowing, and nothing here '
+ 'knows what is already flowing.';
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 phasesOf(phases) {
if (phases !== 'three' && phases !== 'single') {
throw new RangeError(`phases must be "three" or "single", received ${JSON.stringify(phases)}`);
}
return phases;
}
/**
* Amps implied by an apparent power at a stated voltage.
*
* `apparentPowerVa` is volt-amperes and `voltageV` is volts, both in base
* units, because a unit named in a parameter is the only unit check this
* repository has. For a three-phase circuit `voltageV` is the line-to-line
* voltage.
*/
export function currentA({ apparentPowerVa, voltageV, phases = 'three' }) {
positive('apparentPowerVa', apparentPowerVa);
positive('voltageV', voltageV);
phasesOf(phases);
const factor = CURRENT_PHASE_FACTOR[phases];
const amps = apparentPowerVa / (factor * voltageV);
return {
schema,
quantity: 'current_amperes',
value: amps,
unit: 'A',
from: { apparentPowerVa, voltageV, phases, factor },
basis:
'I = S / (' + (phases === 'three' ? 'sqrt(3) x V_line' : 'V') + '). '
+ 'The current a stated apparent power implies at a stated voltage, '
+ 'with no derating and no claim about what flows.',
not_computed: NOT_COMPUTED.actualCurrent,
not_a_headroom: NOT_A_HEADROOM
};
}
/**
* The same question asked in the units the network is actually published in:
* megavolt-amperes and kilovolts. This is the call a rating-envelope result
* feeds, so it exists to stop every caller writing its own 1e6 and 1e3.
*/
export function currentFromMvaAtKv({ mva, kv, phases = 'three' }) {
positive('mva', mva);
positive('kv', kv);
const answer = currentA({
apparentPowerVa: mva * 1e6,
voltageV: kv * 1e3,
phases
});
return { ...answer, from: { mva, kv, phases, factor: answer.from.factor } };
}