In this section
- Standalone geodesy · stars / library/standalone.mjs lines 8240–8939
Standalone
A JavaScript module in the library folder of Stars that maps Renewable Energy Planning Database (REPD) master and heavy emitters UK, using SHA-256, and uses data from the GridAtlas repository.
Set aside from the main view: A comment at the top of the file says a tool wrote it. (noise-generated, proposed by noise.py). All set-aside files, with reasons. Nothing was deleted.
Evidence
- line 2 comment: // Generated by the modular star 2026-12-05T23:26:43.596Z. Each export is one family's earliest-seen copy, unchanged; the comment links its source.
geodesystars / library/standalone.mjs · lines 8240–8939 of 12585 (continued from section 1562) · Entry point · pattern segmentConductors (shared by 2 files)
- What it does
- It maps REPD master, heavy emitters UK, notice and substations. Defines 1111 functions or classes, including f1586_invariant, f8767_representativePoint, f8768_voltagesKv, f8772_voltageOf, f8773_ratingsOf. 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 terms in the code: substations, 750kV, 400kV, 275kV, 132kV, 66kV.
- Inputs & outputs
- In: data source: gridatlas data; JSON file repd_master.json; JSON file heavy_emitters_uk.json; JSON file notice.json; form fields (user input). Out: canvas drawing. Coordinate systems named: OSGB36 / EPSG:27700 (British National Grid), WGS84 / EPSG:4326. Voltage levels named: 750kV, 400kV, 275kV, 132kV, 66kV, 33kV, 1.5kV, 1500V.
- Downstream impact
- Used directly by 4 files: Code (stars, https://ventusltd.github.io/stars/code.html); Proof (stars); Modular Star Workflow (stars); Testcode — Code Record Page (globalgrid2050, https://globalgrid2050.com/testcode/202609141754/code-record/). Reached from 383 other entry points, including Code Generator — Index Page (code-generator, https://ventusltd.github.io/code-generator/); Generate (code-generator, https://ventusltd.github.io/code-generator/); 404 (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/404.html).
- What it achieves
- It snaps coordinate (`snapCoordinate`), paints cursor (`paintCursor`) and sets plan (`setPlan`). Compiled library of self-contained JavaScript functions that appear in two or more places across Ventusltd code. Its code works with 33 kV, 132 kV and 275 kV. It responds to abort events.
- Why it matters
- Loaded by the Code page at https://ventusltd.github.io/stars/code.html and 1 other page. Run by Proof and Modular Star Workflow.
- Application
- stars · library · JavaScript module
- VEDIC
- MEASURE (GG2050-VEDIC-000001): GridAtlas / Geodesy · Mathematics / Spherical geometry. coordinate_pair, coordinate_pair → distance_km
- VEDIC
- REPRESENT (GG2050-VEDIC-000002): GridAtlas / Geodesy · Computer science / Geometry processing. geojson_geometry → coordinate_pair_or_null
- VEDIC
- VOLTAGE (GG2050-VEDIC-000003): GridAtlas / Geodesy · Computer science / Data normalisation. voltage_properties → kilovolt_list
- Uses
- GlobalGrid2050 — Renewable Energy Planning Database (REPD) Grid Atlas v8 Page (estate URL), Declared Connections (estate URL)
- Used by
- named by URL in Code (estate URL), run by Proof (script call), run by Modular Star Workflow (workflow run), named by URL in Testcode — Code Record Page (estate URL)
- Produces
- f1586_invariant, f8767_representativePoint, f8768_voltagesKv, f8772_voltageOf, f8773_ratingsOf, f8775_parametersOf, f5168_escapeHTML, f8321_suppliedArrivalFields, f8850__anonymous_, f8786_crossing, f8788_legality, f8789_startNodes
- Defines here
- build, extraAfter, rowOf0, turned, x0, ptAt, minusPt, minus, inRow, run, run, f139544_place, T, N2, f139898_normalisePlan, f139901_collect, f139902_inputStatus, f139905__anonymous_, tempFactor, ohmPerKmAt, normalisePlan, segmentConductors, connectorPairs, collect, inputStatus, stringResistance, ampacity, f140693_tubeHullOf, cr, f140694_tubeSwell
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- stars@030ebc202d35959fecd162327892f671d1d9a0cc library/standalone.mjs:8240-8939 · blob fc3d8c8b93e14d4a56b8a26da47071d60bc5bc4d · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, filesystem, network, storage · domain stage: unknown · users: none · canonical: unknown
: 'fixed tilt, ' + g.rows + ' in ' + o + (g.rows > 1 ? ' high' : '');
return m; };
// ===== THE TABLE. A string is not a row; a row is a table one module high. =====================
// A module's two boxes sit at MID LENGTH OF ITS LONG SIDE, spread along its SHORT axis. That is one
// rule and it settles both orientations without a special case: in PORTRAIT the long side is upright,
// so the - and the + sit side by side ALONG the table; in LANDSCAPE the module is turned a quarter
// turn, the long side is now horizontal, and the two boxes sit one ABOVE the other. Everything else -
// where the modules are, how far a link has to reach, what is laid on site - follows from that and
// from the grid. A table one module high in portrait reproduces the old row model to the digit, which
// is asserted rather than hoped for.
function build(inp) {
const c = Object.assign({}, DEF, inp || {}), N = Math.max(2, Math.min(60, Math.round(c.modules)));
const port = String(c.orientation || 'portrait').toLowerCase() !== 'landscape';
const wX = port ? c.width_m : c.module_height_m, wY = port ? c.module_height_m : c.width_m;
const pitch = wX + c.gap_m, pitchY = wY + c.gap_up_m;
const mount = String(c.mounting || 'fixed').toLowerCase();
const high = Math.max(1, Math.min(6, Math.round(c.modules_high)));
const faces = mount === 'east-west' ? 2 : 1, rows = high * faces;
const cols = Math.max(1, Math.ceil(N / rows));
// WHAT STANDS BETWEEN TWO ROWS: nothing on a plain table, the ridge on an east west table, the torque
// tube down the middle of a tracker.
const extraAfter = r => (faces === 2 && r === high - 1) ? c.ridge_gap_m
: (mount === 'tracker' && r === Math.floor(rows / 2) - 1) ? c.tube_gap_m : 0;
const rowY = []; { let yy = 0; for (let r = 0; r < rows; r++) { rowY.push(yy); yy += pitchY + extraAfter(r); } }
// ROUTING is what the old "wiring" input was asking, and it is kept as a name for it.
let routing = String(c.routing || '').toLowerCase();
if (!routing) routing = String(c.wiring).toLowerCase() === 'sequential' ? 'one-after-another' : 'leapfrog';
if (routing === 'along-and-back' || routing === 'sequential-u') routing = 'serpentine';
if (routing === 'sequential') routing = 'one-after-another';
if (routing === 'zigzag' && rows < 2) routing = 'one-after-another';
if (routing === 'serpentine' && rows < 2) routing = 'one-after-another';
c.routing = routing;
const leap = routing === 'leapfrog';
// THE DEFAULT STRING IS A COMPLETE STRING. Nobody builds an array and leaves half its links open;
// a drawing that opens by default is a drawing of a mistake. So unless a lead length is typed, the
// leads are THE PAIR THAT REACHES for the wiring chosen - the longest link plus the slack allowance
// - and the answer says what pair that is, to be ordered against what the module is supplied with.
// Ask for "supplied" instead and you get the factory portrait leads and, with them, the shortfall.
const leadsAre = String(c.leads || 'reach').toLowerCase();
const typedLeads = c.lead_plus_m !== null || c.lead_minus_m !== null;
if (leadsAre === 'supplied' && !typedLeads) { c.lead_plus_m = 0.35; c.lead_minus_m = 0.28; }
const rowOf0 = k => Math.min(rows - 1, Math.floor((k - 1) / cols)), colOf = k => (k - 1) % cols;
const turned = k => (!!c.turn_every_second && k % 2 === 0) !== (!!c.turn_alternate_rows && rowOf0(k) % 2 === 1);
const rowOf = rowOf0;
const x0 = k => colOf(k) * pitch, y0 = k => rowY[rowOf(k)];
const s2 = c.box_spacing_m / 2;
const ptAt = (k, want, t) => { const cxm = x0(k) + wX / 2, cym = y0(k) + wY / 2, d = (want === '+' ? 1 : -1) * (t ? -1 : 1) * s2;
return port ? [cxm + d, cym] : [cxm, cym + d]; };
const minusPt = k => ptAt(k, '-', turned(k)), plusPt = k => ptAt(k, '+', turned(k));
const minus = k => minusPt(k)[0], plus = k => plusPt(k)[0]; // the drawing reads x from these
// THE ORDER THE STRING IS WIRED IN, over the grid of modules. The modules themselves never move.
const inRow = r => { const out = []; for (let k = 1; k <= N; k++) if (rowOf(k) === r) out.push(k); return out; };
const order = [];
if (routing === 'leapfrog') { for (let r = 0; r < rows; r++) { const q = inRow(r); if (!q.length) continue;
const fwd = r % 2 === 0 ? q : q.slice().reverse();
for (let i = 0; i < fwd.length; i += 2) order.push(fwd[i]);
for (let i = (fwd.length % 2 ? fwd.length - 2 : fwd.length - 1); i >= 1; i -= 2) order.push(fwd[i]); } }
else if (routing === 'serpentine') { for (let r = 0; r < rows; r++) { const q = inRow(r); if (!q.length) continue;
order.push(...(r % 2 === 0 ? q : q.slice().reverse())); } }
else if (routing === 'zigzag') { const a0 = inRow(0), a1 = inRow(1);
for (let i = 0; i < Math.max(a0.length, a1.length); i++) { const up = i % 2 === 0;
if (up) { if (a0[i] !== undefined) order.push(a0[i]); if (a1[i] !== undefined) order.push(a1[i]); }
else { if (a1[i] !== undefined) order.push(a1[i]); if (a0[i] !== undefined) order.push(a0[i]); } }
for (let r = 2; r < rows; r++) { const q = inRow(r); order.push(...(r % 2 === 0 ? q : q.slice().reverse())); } }
else for (let k = 1; k <= N; k++) order.push(k);
// HOW FAR EACH LINK HAS TO REACH IS GEOMETRY, and it does not depend on what lead is fitted: so the
// needs are measured first, and only then is the lead pair settled.
const links = [];
for (let i = 0; i + 1 < order.length; i++) { const from = order[i], to = order[i + 1];
const A = plusPt(from), B = minusPt(to);
const need = Math.hypot(A[0] - B[0], A[1] - B[1]) + (+c.slack_m || 0);
links.push({ from, to, need, back: to < from, cross: rowOf(from) !== rowOf(to),
x_from: A[0], x_to: B[0], y_from: A[1], y_to: B[1] }); }
const longest = links.length ? Math.max(...links.map(l => l.need)) : 0;
if (c.lead_plus_m === null || c.lead_minus_m === null) {
const want = longest + (c.lead_slack_m === undefined ? 0.20 : +c.lead_slack_m);
// the + lead keeps the box spacing it really has and the - lead makes up the rest, which is how
// a module maker quotes an unequal pair
const lpWant = Math.min(want * 0.5, c.box_spacing_m);
if (c.lead_plus_m === null) c.lead_plus_m = Math.round(lpWant * 1000) / 1000;
if (c.lead_minus_m === null) c.lead_minus_m = Math.round((want - c.lead_plus_m) * 1000) / 1000; }
const pair = c.lead_plus_m + c.lead_minus_m;
for (const l of links) { l.reaches = pair + 1e-9 >= l.need;
l.jumper = !l.reaches && !!c.jumpers ? l.need - pair : 0; }
const last = order[order.length - 1], row = cols * pitch;
// HOW FAR A FREE END IS FROM THE NEAR CORNER, along the structure: a cable is clipped to steel, it
// does not fly. Both ends land at the near end when the + end is in the near half of the table.
const yBase = rowY[0] + wY / 2;
const run = q => Math.abs(q[0]) + Math.abs(q[1] - yBase);
const endRun = run(plusPt(last)), bothNear = endRun <= row / 2;
const ret = bothNear ? 0 : endRun;
// conductor_c, when it is given, is the name for both: it sets the lead and the site cable together.
if (c.conductor_c !== null && c.conductor_c !== undefined && c.conductor_c !== '') { c.t_lead_c = +c.conductor_c; c.t_site_c = +c.conductor_c; }
const fLead = 1 + 0.00393 * (c.t_lead_c - 20), fSite = 1 + 0.00393 * (c.t_site_c - 20);
// A JUMPER IS SITE CABLE AND ONE MORE MATED PAIR, at the link it is spliced into.
const jumpers = links.filter(l => l.jumper > 0), jumper_m = jumpers.reduce((t, l) => t + l.jumper, 0);
const lead_m = N * pair, field_m = 2 * c.near_end_m + run(minusPt(order[0])) + endRun + jumper_m;
const pairs = links.length + 2 + (bothNear ? 0 : 1) + jumpers.length;
// A SITE MADE END is a connector fitted to a cut cable by a person on the table: the two home runs
// always, and the far end return cable's two, when one is laid.
const siteEnds = 2 + (bothNear ? 0 : 2);
const ohmLead = (R20[c.lead_mm2] || 5.09) * lead_m * fLead / 1000;
const ohmSite = (R20[c.cable_mm2] || 3.39) * field_m * fSite / 1000;
const ohm = ohmLead + ohmSite + pairs * c.contact_milliohm / 1000;
const short = links.filter(l => !l.reaches && !l.jumper), needs = links.map(l => l.need);
// THREE LOOPS, NOT ONE. The array's own loop is what the wiring choice changes; the home run pair is
// its own loop and on a long run it is the larger; a nearby stroke couples into the SUM of them.
const arrayLoop = bothNear ? row * c.lead_gap_m : row * c.return_offset_m;
const sep = (c.home_separation_m === null || c.home_separation_m === undefined || c.home_separation_m === '') ? null : +c.home_separation_m;
const homeLoop = sep === null ? null : c.near_end_m * sep;
const loop = homeLoop === null ? null : arrayLoop + homeLoop;
// A CONDUCTOR OVER ITS RATING IS SAID IN WORDS AND NEVER QUIETLY COSTED.
const hot = [];
if (c.t_lead_c > c.rating_c) hot.push('the module leads at ' + c.t_lead_c + ' C are over the ' + c.rating_c + ' C the cable is rated for');
if (c.t_site_c > c.rating_c) hot.push('the site cable at ' + c.t_site_c + ' C is over the ' + c.rating_c + ' C it is rated for');
// WHAT IS NOT LAID ON SITE, against ONE stated baseline: the same row wired one after another, no
// module turned, with its far end brought home. Closed form, so it can be checked by hand:
// plain leapfrog saves (N-2) pitches; turning every second module saves (N-2) pitches and the box
// spacing as well, because the last module's + box has moved to the near side of its own module.
const baseEnd = Math.abs(ptAt(N, '+', false)[0]) + Math.abs(ptAt(N, '+', false)[1] - yBase);
const baseField = 2 * c.near_end_m + Math.abs(ptAt(1, '-', false)[0]) + Math.abs(ptAt(1, '-', false)[1] - yBase) + baseEnd;
const saved = baseField - field_m;
const smallest = needs.length ? Math.max(...needs) : 0;
return { c, N, pitch, pitchY, wX, wY, port, rows, cols, rowY, mount, high, faces, routing, leap, order, links,
row, pair, lead_m, field_m, pairs, siteEnds, ohm, ohmLead, ohmSite, bothNear, endRun, ret,
short, needs, smallest, jumpers, jumper_m, loop, arrayLoop, homeLoop, sep, saved, hot, fLead, fSite,
minusPt, plusPt, minus, plus, rowOf, colOf, x0, y0, turned };
}
function run(inp) {
const g = build(inp), c = g.c, worst = g.short.length ? Math.max(...g.short.map(l => l.need - g.pair)) : 0;
const name = LAYOUT_WORDS(g) + ', ' + (ROUTE_WORDS[g.routing] || g.routing)
+ (c.turn_every_second ? ', every second module turned end for end' : '');
// A SERIES CIRCUIT IS OPEN OR IT IS NOT. One pair of connectors that does not meet and the whole
// string carries nothing: not a warm link, not a derated string, NOTHING, anywhere in it.
const open = g.short.length > 0, amps = open ? 0 : c.amps;
// AN OPEN STRING IS NOT A DEAD STRING. No current flows, and that is the whole of what "open" means;
// the modules go on making their open circuit voltage, so the full string voltage stands across a
// break, and an open connector under that voltage is exactly where a direct current arc begins.
const voc = g.N * c.module_voc;
const order = g.order.map(k => 'M' + k).join(' → ');
const hotWords = g.hot.length ? ' RATING CHECK FAILED: ' + g.hot.join('; ') + '. ' : '';
const loopWords = g.sep === null
? ' The whole loop needs the home run separation: it moves the answer more than the wiring does, so only the array loop is given.'
: ' Loop ' + g.loop.toFixed(1) + ' m2 in all, of which the home run pair is ' + g.homeLoop.toFixed(1) + ' m2.';
const said = hotWords + name + ': ' + g.N + ' modules over ' + g.rows + (g.rows === 1 ? ' row' : ' rows') + ' of ' + g.cols + ', ' + g.links.length + ' links from ' + Math.min(...g.needs).toFixed(2) + ' to ' + Math.max(...g.needs).toFixed(2) + ' m against a lead pair of ' + g.pair.toFixed(2) + ' m; '
+ (g.bothNear ? 'both free ends land at the near end, so no return cable is laid; ' : 'a return cable of ' + g.ret.toFixed(1) + ' m brings the far end home; ')
+ (g.jumpers.length ? g.jumpers.length + (g.jumpers.length === 1 ? ' link is' : ' links are') + ' made up with a jumper spliced in on site, ' + g.jumper_m.toFixed(1) + ' m of cable and ' + g.jumpers.length + ' more mated pairs; ' : '')
+ (open ? 'THE CIRCUIT IS OPEN AND BOTH ENDS ARE LIVE: ' + g.short.length + ' links do not reach (short by up to ' + worst.toFixed(2) + ' m), so no current flows anywhere, but up to '
+ voc.toFixed(0) + ' V stands across a break and an open connector at that voltage is where a direct current arc starts'
: 'every link reaches, so the loop closes and ' + c.amps + ' A flows all the way round it')
+ '; ' + g.lead_m.toFixed(1) + ' m of module lead and ' + g.field_m.toFixed(1) + ' m of cable laid on site; '
+ loopWords + ' '
+ (open ? g.ohm.toFixed(3) + ' ohm IF IT WERE CLOSED, and ' + (c.amps * c.amps * g.ohm).toFixed(0) + ' W lost at ' + c.amps + ' A: nothing is lost in it now because nothing flows in it'
: g.ohm.toFixed(3) + ' ohm, ' + (amps * amps * g.ohm).toFixed(0) + ' W lost at ' + amps + ' A');
// THE CONNECTION LIST, in the order the current runs, terminal by terminal. It is the same walk the
// checks make, so what a reader sees in words is what the drawing was built from.
const connections = [{ from:'INV\u2212', to:'M' + g.order[0] + '\u2212', metres:c.near_end_m, home:true, node:'home-' }];
g.links.forEach((l, i) => connections.push({ node:'L' + i, from:'M' + l.from + '+', to:'M' + l.to + '\u2212',
needed:rnd(l.need, 2), pair:rnd(g.pair, 2), reaches:l.reaches, jumper:rnd(l.jumper || 0, 2) }));
connections.push({ from:'M' + g.order[g.order.length - 1] + '+', to:'INV+', metres:c.near_end_m, home:true, node:'home+' });
return { connections, numbers: { circuit: open ? 'OPEN, both ends live' : 'closed', current_a: rnd(amps, 2),
open_circuit_volts_at_25c: rnd(voc, 0), volts_across_a_break: open ? rnd(voc, 0) : 0, links: g.links.length,
shortest_link_m: rnd(Math.min(...g.needs), 3), longest_link_m: rnd(Math.max(...g.needs), 3), lead_pair_m: rnd(g.pair, 3),
links_that_do_not_reach: g.short.length, worst_shortfall_m: rnd(worst, 3), module_lead_m: rnd(g.lead_m, 1), cable_laid_on_site_m: rnd(g.field_m, 1),
total_conductor_m: rnd(g.lead_m + g.field_m, 1), connector_pairs: g.pairs, string_resistance_ohm: rnd(g.ohm, 4), loss_w: rnd(amps * amps * g.ohm, 1),
volt_drop_v: rnd(amps * g.ohm, 2), row_length_m: rnd(g.row, 2), string_volts_at_vmp: rnd(g.N * c.module_vmp, 0),
loss_w_if_it_were_closed: rnd(c.amps * c.amps * g.ohm, 1),
volts_to_earth_each_end: '−' + rnd(g.N * c.module_vmp / 2, 0) + ' to +' + rnd(g.N * c.module_vmp / 2, 0),
routing: g.routing, rows_of_modules: g.rows, columns_of_modules: g.cols,
modules_in_the_last_column: g.N - (g.cols - 1) * g.rows > 0 ? Math.min(g.rows, g.N - (g.cols - 1) * g.rows) : g.rows,
both_ends_at_the_near_end: g.bothNear, return_cable_m: rnd(g.ret, 2),
smallest_lead_pair_that_reaches_m: rnd(g.smallest, 3),
lead_pair_to_order_m: rnd(g.pair, 3),
connectors_fitted_on_site: g.siteEnds + 2 * g.jumpers.length,
jumpers_made_on_site: g.jumpers.length, jumper_cable_m: rnd(g.jumper_m, 2),
array_loop_m2_rough: rnd(g.arrayLoop, 2),
home_run_loop_m2_rough: g.homeLoop === null ? null : rnd(g.homeLoop, 2),
total_loop_m2_rough: g.loop === null ? null : rnd(g.loop, 2),
site_cable_saved_m: rnd(g.saved, 2),
lead_resistance_ohm: rnd(g.ohmLead, 4), site_cable_resistance_ohm: rnd(g.ohmSite, 4),
rating_check: g.hot.length ? 'FAILED: ' + g.hot.join('; ') : 'passed, both conductors at or under ' + c.rating_c + ' C' },
said, electrical_order: order,
how: 'geometry only: module ' + c.width_m + ' m wide by ' + c.module_height_m + ' m tall in portrait, ' + c.cell_cols + ' by ' + c.cell_rows
+ ' half cells, junction boxes ' + c.box_spacing_m + ' m apart at mid height, a link is the distance between the boxes it joins; leads ' + c.lead_mm2 + ' mm2, site cable ' + c.cable_mm2
+ ' mm2, copper, the leads at ' + c.t_lead_c + ' C and the site cable at ' + c.t_site_c + ' C (give conductor_c and both take that figure); near end ' + c.near_end_m + ' m from the inverter. '
+ 'The site cable temperature is an assumption and it matters: buried is about 30 C, clipped along the structure is near the lead temperature; ' + c.t_site_c + ' C was used here. '
+ 'A link has to span the STRAIGHT DISTANCE IN THE PLANE between the two boxes plus the slack allowance, ' + (+c.slack_m || 0) + ' m here. '
+ 'The boxes sit at mid length of the module\u2019s long side, spread along its short axis, so in portrait they are side by side along the table and in landscape one above the other. '
+ 'A cable to a free end is counted along the structure, not across the diagonal. '
+ 'The loop is in two parts, both rough: the ARRAY loop is the row length times a stated gap, and the HOME RUN loop is the run times how far apart the two cables are laid. '
+ 'Bundling the home run pair shrinks the loop more than the wiring choice does, for either wiring. '
+ 'Site cable not laid, against the same row wired one after another with no module turned and its far end brought home: ' + g.saved.toFixed(2) + ' m. '
+ 'Electrical order ' + order + '. Colour is the POTENTIAL RELATIVE TO THE MINUS TERMINAL, not to earth: the array floats, so either terminal may sit at up to half the '
+ 'array voltage with respect to earth, and a black line does not mean an earthed one. The line does not thicken or thin along the string, because a series circuit carries one current. '
+ 'The moving highlight is the INSTANT THE CIRCUIT CLOSES; after that the current is the same all the way round and nothing travels along the wire. An open string carries no current and is NOT safe: up to '
+ rnd(voc, 0) + ' V at 25 C stands across a break, more when it is cold. '
+ 'Every input can be changed. An estimate, not a study.', string: g, inputs_used: Object.assign({}, c) };
}
// WHAT A READER MAY TURN, in plain words with its unit. The window makes a box out of each of these.
const BOXES = [
{ key:'mounting', label:'mounting', kind:'choice', choices:[['fixed', 'fixed tilt'], ['east-west', 'east and west facing'], ['tracker', 'single axis tracker']] },
{ key:'orientation', label:'modules', kind:'choice', choices:[['portrait', 'portrait'], ['landscape', 'landscape']] },
{ key:'modules_high', label:'modules high (each face)', kind:'number', min:1, max:6, step:1 },
{ key:'turn_alternate_rows', label:'return rows turned round', kind:'choice', choices:[[0, 'no'], [1, 'yes']] },
{ key:'jumpers', label:'jumper where leads fall short', kind:'choice', choices:[[0, 'no, say it is open'], [1, 'yes, splice one in']] },
{ key:'view', label:'drawn as', kind:'choice', choices:[['wiring', 'the back, wiring'], ['scale', 'modules to scale']] },
{ key:'sheet', label:'on', kind:'choice', choices:[[0, 'the night sky'], [1, 'a drawing sheet']] },
{ key:'routing', label:'routing', kind:'choice', choices:[
['one-after-another', 'one after another, with a return cable'],
['serpentine', 'along and back, no return cable'],
['leapfrog', 'leapfrog inside each row'],
['zigzag', 'zigzag between two rows']] },
{ key:'turn_every_second', label:'every second module turned', kind:'choice', choices:[[0, 'no'], [1, 'yes']] },
{ key:'modules', label:'modules', kind:'number', min:2, max:40, step:1 },
{ key:'width_m', label:'module width', unit:'m', kind:'number', min:0.4, max:3, step:0.001 },
{ key:'module_height_m', label:'module height', unit:'m', kind:'number', min:0.4, max:4, step:0.001 },
{ key:'gap_m', label:'gap along the table', unit:'m', kind:'number', min:0, max:1, step:0.005 },
{ key:'gap_up_m', label:'gap up the table', unit:'m', kind:'number', min:0, max:1, step:0.005 },
{ key:'ridge_gap_m', label:'gap at the ridge', unit:'m', kind:'number', min:0, max:2, step:0.01 },
{ key:'tube_gap_m', label:'gap at the torque tube', unit:'m', kind:'number', min:0, max:2, step:0.01 },
{ key:'box_spacing_m', label:'junction boxes apart', unit:'m', kind:'number', min:0.05, max:2, step:0.01 },
{ key:'leads', label:'leads', kind:'choice', choices:[['reach', 'the pair that reaches'], ['supplied', 'as supplied, portrait']] },
{ key:'lead_slack_m', label:'slack in the lead pair', unit:'m', kind:'number', min:0, max:2, step:0.01 },
{ key:'lead_plus_m', label:'+ lead', unit:'m', kind:'number', min:0.05, max:8, step:0.01 },
{ key:'lead_minus_m', label:'− lead', unit:'m', kind:'number', min:0.05, max:8, step:0.01 },
{ key:'lead_mm2', label:'lead size', unit:'mm2', kind:'choice', choices:[[2.5, '2.5'], [4, '4'], [6, '6'], [10, '10']] },
{ key:'cable_mm2', label:'site cable', unit:'mm2', kind:'choice', choices:[[4, '4'], [6, '6'], [10, '10']] },
{ key:'near_end_m', label:'near end from the inverter', unit:'m', kind:'number', min:0, max:400, step:1 },
{ key:'amps', label:'current', unit:'A', kind:'number', min:0.1, max:40, step:0.01 },
{ key:'t_lead_c', label:'module lead temperature', unit:'C', kind:'number', min:-25, max:140, step:1 },
{ key:'t_site_c', label:'site cable temperature', unit:'C', kind:'number', min:-25, max:140, step:1,
hint:'buried is about 30, clipped along the structure is near the lead temperature' },
{ key:'rating_c', label:'cable rated for', unit:'C', kind:'number', min:60, max:140, step:5 },
{ key:'home_separation_m', label:'home run cables apart', unit:'m', kind:'number', min:0, max:2, step:0.01,
optional:true, hint:'bundled about 0.02, separate trays about 0.3' },
{ key:'slack_m', label:'slack allowed at each link', unit:'m', kind:'number', min:0, max:2, step:0.01 },
{ key:'module_vmp', label:'module at most power', unit:'V', kind:'number', min:5, max:100, step:0.1 },
{ key:'module_voc', label:'module open circuit', unit:'V', kind:'number', min:5, max:120, step:0.1 },
// ROOM LEFT HERE, deliberately, for inputs already agreed and not yet built: how far apart the two
// home runs are laid (which decides the home run's own loop area separately from the array's), and
// the lead temperature and the site cable temperature as two figures, with the single conductor
// temperature kept as the name for both.
{ key:'cell_cols', label:'cells across', kind:'number', min:1, max:24, step:1 },
{ key:'cell_rows', label:'cells up', kind:'number', min:2, max:48, step:2 }
];
F.register('string', 'STRINGS', run, BOXES);
F.string = { build, DEF, BOXES };
};
// Family #139544 · element #139544 · 15 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/i0083/cartridges/007700000000-kuiper-programs.js#L870-L887
export const f139544_place = function place(d, f, dy, tag) {
const T = (x, y) => [-0.95 + (x + 0.95) * f, y * f + dy];
const N2 = n => (n === null || n === undefined) ? n : tag + n;
for (const s of d.shapes) {
if (s.pts) s.pts = s.pts.map(p => T(p[0], p[1]));
if (s.split) s.split = s.split.map(p => T(p[0], p[1]));
if (s.lines) s.lines = s.lines.map(l => [T(l[0][0], l[0][1]), T(l[1][0], l[1][1])]);
if (s.mid) s.mid = T(s.mid[0], s.mid[1]);
if (typeof s.dot === 'number') s.dot = s.dot * f;
s.node = N2(s.node); }
for (const m of d.marks) { const u = T(m.x, m.y); m.x = u[0]; m.y = u[1]; }
for (const t of d.terminals) { const u = T(t.x, t.y); t.x = u[0]; t.y = u[1]; t.id = tag + t.id; }
for (const w of d.words) { if (w.pinned !== undefined) continue; const u = T(w.x, w.y); w.x = u[0]; w.y = u[1]; }
for (const cr of (d.crossings || [])) { const u = T(cr.x, cr.y); cr.x = u[0]; cr.y = u[1];
cr.over = N2(cr.over); cr.under = N2(cr.under); }
d.perM = d.perM * f;
return d;
};
// Family #139898 · element #139898 · 15 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/i0083/cartridges/008000000000-kuiper-programs.js#L781-L788
export const f139898_normalisePlan = function normalisePlan(plan, L) { // metres win over fractions
const steps = plan.map(s => Object.assign({}, s));
let fixed = 0, fracTotal = 0;
for (const s of steps) { if (typeof s.length_m === 'number') fixed += s.length_m; else fracTotal += (typeof s.frac === 'number' ? s.frac : 1); }
const left = Math.max(0, L - fixed);
for (const s of steps) if (typeof s.length_m !== 'number') { const f = typeof s.frac === 'number' ? s.frac : 1; s.length_m = fracTotal === 0 ? 0 : left * f / fracTotal; }
return steps;
};
// Family #139901 · element #139901 · 15 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/i0083/cartridges/008000000000-kuiper-programs.js#L815-L822
export const f139901_collect = function collect(defaults, user) {
const out = {};
for (const k of Object.keys(defaults)) {
const d = defaults[k], has = user && user[k] !== undefined && user[k] !== null;
out[k] = { key:k, value: has ? user[k] : d.value, status: has ? 'TYPED' : 'ASSUMED', source: has ? 'typed by the user' : d.source };
}
return out;
};
// Family #139902 · element #139902 · 15 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/i0083/cartridges/008000000000-kuiper-programs.js#L823-L827
export const f139902_inputStatus = function inputStatus(inputs) {
const all = Object.keys(inputs).map(k => inputs[k]), assumed = all.filter(v => v.status === 'ASSUMED');
return { n:all.length, assumed:assumed.length, typed:all.length - assumed.length,
words: assumed.length + ' of ' + all.length + ' inputs assumed', assumed_keys:assumed.map(v => v.key) };
};
// Family #139905 · element #139905 · 15 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/i0083/cartridges/008000000000-kuiper-programs.js#L747-L880
export const f139905__anonymous_ = function () {
// --- 1. DATA, copied value for value ---------------------------------------------------------
const R20 = { 1.5:13.7, 2.5:8.21, 4:5.09, 6:3.39, 10:1.95, 16:1.24 }; // the conductor standard, class 5 tinned, maximum R20 ohm/km — by clause and value only
const ALPHA = 0.00393; // copper, from 20 C
const A3 = { single_free_in_air:{2.5:41,4:55,6:70,10:98,16:132},
single_on_a_surface:{2.5:39,4:52,6:67,10:93,16:125},
two_loaded_touching_on_a_surface:{2.5:33,4:44,6:57,10:79,16:107} }; // the PV cable standard, Table A.3, stated at 60 C ambient
const K_AMB = { 60:1.0, 70:0.92, 80:0.84, 90:0.75 }; // Table A.4. REFUSE above 90 C rather than extrapolate.
const IN_SUN = { 'frame-clip':true, 'c-rail':true, tray:true, 'conduit-duct':false, buried:false, 'free-air':true };
// The array standard wants + and − bundled to hold the loop area down, so the PAIRED column
// applies everywhere the pair is bundled — which is everywhere but a genuinely single free-air run.
const METHOD = { 'frame-clip':'two_loaded_touching_on_a_surface', 'c-rail':'two_loaded_touching_on_a_surface',
tray:'two_loaded_touching_on_a_surface', 'conduit-duct':'two_loaded_touching_on_a_surface',
buried:'two_loaded_touching_on_a_surface', 'free-air':'single_free_in_air' };
// THE PRESET PROPOSAL: what containment each kind of conductor gets before anybody types
// anything — leads clipped to the frame, the along-table run on C rail, the home run on tray to
// the edge of the block and then in duct to the inverter. The 60/40 split is ASSUMED. It is a
// declared input: pass containment:{site:'conduit-duct'} or a full per-kind plan to change it.
const PRESET = { lead:[{ containment:'frame-clip', frac:1 }], site:[{ containment:'c-rail', frac:1 }],
homerun:[{ containment:'tray', frac:0.6 }, { containment:'conduit-duct', frac:0.4 }] };
// One inverter block: 24 strings, home runs declared band by band. Mean 45 m, which is the
// practice mode and matches the 44.61 m a string the farm file implies. ASSUMED.
const BANDS = [{ strings:8, home_run_m:20 }, { strings:8, home_run_m:45 }, { strings:8, home_run_m:70 }];
// THE FARM IS READ, NOT RECOMPUTED. These km were summed block by block by the bench.
const FARM = { blocks:963, strings:20222, builds: {
sequential: { lead_km:382.196, site_km:2570.336 },
'leapfrog-turned': { lead_km:1216.960, site_km:1804.246 },
'leapfrog-two-lead-lengths': { lead_km:1726.554, site_km:1821.233 } } };
const FARM_BUILD = { sequential:'sequential', leapfrog:'leapfrog-two-lead-lengths', 'leapfrog-turned':'leapfrog-turned' };
const LABEL = { sequential:'sequential', leapfrog:'leapfrog', 'leapfrog-turned':'leapfrog rear-turned' };
// --- 3. CABLE MATHS --------------------------------------------------------------------------
const tempFactor = t => 1 + ALPHA * (t - 20);
const ohmPerKmAt = (mm2, t) => (R20[mm2] || R20[4]) * tempFactor(t);
// --- 4. SEGMENTS. Split every conductor's route into segments with a containment. -------------
function normalisePlan(plan, L) { // metres win over fractions
const steps = plan.map(s => Object.assign({}, s));
let fixed = 0, fracTotal = 0;
for (const s of steps) { if (typeof s.length_m === 'number') fixed += s.length_m; else fracTotal += (typeof s.frac === 'number' ? s.frac : 1); }
const left = Math.max(0, L - fixed);
for (const s of steps) if (typeof s.length_m !== 'number') { const f = typeof s.frac === 'number' ? s.frac : 1; s.length_m = fracTotal === 0 ? 0 : left * f / fracTotal; }
return steps;
}
function segmentConductors(conductors, opts) {
opts = opts || {}; const preset = opts.preset || PRESET, overrides = opts.overrides || {};
const segments = [];
for (const c of conductors) {
const L = c.length_m, plan = normalisePlan(overrides[c.id] || preset[c.kind] || [{ containment:'free-air', frac:1 }], L);
let acc = 0;
plan.forEach((step, i) => {
const segLen = i === plan.length - 1 ? L - acc : step.length_m; // the last step absorbs the crumbs so the sum is exact
segments.push({ id:c.id + '#' + i, conductor_id:c.id, kind:c.kind, index:i, containment:step.containment,
in_sun: IN_SUN[step.containment] === true, length_m:segLen, circuits_sharing:1,
run_id:(step.containment === 'tray' || step.containment === 'conduit-duct' || step.containment === 'buried')
? step.containment + ':block' : step.containment + ':string' });
acc += segLen;
});
}
const runs = new Map(); // circuits_sharing = conductors in the same containment run
for (const s of segments) { if (!runs.has(s.run_id)) runs.set(s.run_id, new Set()); runs.get(s.run_id).add(s.conductor_id); }
for (const s of segments) s.circuits_sharing = runs.get(s.run_id).size;
return { segments, total_length_m: segments.reduce((t, s) => t + s.length_m, 0) };
}
// --- 5. CONNECTOR COUNT ----------------------------------------------------------------------
// sequential N+2 mated pairs, leapfrog (either) N+1 — BENCH. The far end is the difference: a
// sequential string is joined to its return run out there, a leapfrog string is not.
const connectorPairs = (wiring, N) => ({ factory_mated:N - 1, site_made: wiring === 'sequential' ? 3 : 2,
total: N - 1 + (wiring === 'sequential' ? 3 : 2) });
// --- 2. INPUT STATUS. Every value is TYPED or ASSUMED and the count is reported. --------------
function collect(defaults, user) {
const out = {};
for (const k of Object.keys(defaults)) {
const d = defaults[k], has = user && user[k] !== undefined && user[k] !== null;
out[k] = { key:k, value: has ? user[k] : d.value, status: has ? 'TYPED' : 'ASSUMED', source: has ? 'typed by the user' : d.source };
}
return out;
}
function inputStatus(inputs) {
const all = Object.keys(inputs).map(k => inputs[k]), assumed = all.filter(v => v.status === 'ASSUMED');
return { n:all.length, assumed:assumed.length, typed:all.length - assumed.length,
words: assumed.length + ' of ' + all.length + ' inputs assumed', assumed_keys:assumed.map(v => v.key) };
}
// --- 6. SERIES RESISTANCE BUILD-UP, one string -----------------------------------------------
function stringResistance(o) {
const T = o.conductor_temp_c, n = Math.max(1, o.n_parallel);
const mm2 = { lead:o.lead_mm2, site:o.site_mm2, homerun:o.homerun_mm2 };
const parallelKinds = o.parallel_scope === 'all' ? ['lead','site','homerun'] : ['site','homerun'];
const seg = segmentConductors(o.conductors, { preset:o.preset, overrides:o.containment_overrides });
const by = { lead:0, site:0, homerun:0 }, r = { lead:0, site:0, homerun:0 };
for (const c of o.conductors) {
const kind = by[c.kind] !== undefined ? c.kind : 'site';
by[kind] += c.length_m;
const rr = c.length_m / 1000 * ohmPerKmAt(mm2[kind], T);
r[kind] += parallelKinds.indexOf(kind) >= 0 ? rr / n : rr; // n cables a pole divide the laid cable, never the module leads
}
const pairs = connectorPairs(o.wiring, o.modules_per_string);
const r_contact_ohm = pairs.total * o.contact_mohm_per_pair / 1000;
const r_cable_ohm = r.lead + r.site + r.homerun, r_total_ohm = r_cable_ohm + r_contact_ohm;
const imp = o.module_imp_a, vmp = o.modules_per_string * o.module_vmp_v, p = imp * vmp;
return { wiring:o.wiring, wiring_label:LABEL[o.wiring] || o.wiring, length_m:by.lead + by.site + by.homerun,
length_by_kind_m:by, segments:seg.segments,
resistance:{ r_lead_ohm:r.lead, r_site_ohm:r.site, r_homerun_ohm:r.homerun, r_cable_ohm, r_contact_ohm, r_total_ohm },
connectors:pairs, current_a:imp, vmp_string_v:vmp, p_string_w:p,
vdrop_v:imp * r_total_ohm, vdrop_pct:imp * r_total_ohm / vmp * 100,
loss_w:imp * imp * r_total_ohm, loss_pct:imp * imp * r_total_ohm / p * 100 };
}
// --- 7. AMPACITY. NO DEFAULT GROUP FACTOR, ON PURPOSE. ---------------------------------------
// The group factor decides the check, so a default would at once become an input divided by an
// input. Without one the verdict is null and the reason is: group factor must be typed. The
// SITUATION still comes back, because that is what a person needs in order to type the factor.
function ampacity(o) {
const method = METHOD[o.containment] || 'two_loaded_touching_on_a_surface';
const table_value_a = (A3[method] || {})[o.csa_mm2];
const k = K_AMB[o.ambient_c] !== undefined ? K_AMB[o.ambient_c] : null;
const design_current_a = o.module_isc_a * o.design_current_factor / Math.max(1, o.n_parallel);
const out = { containment:o.containment, csa_mm2:o.csa_mm2, ambient_c:o.ambient_c,
situation:{ circuits_sharing:o.circuits_sharing, containment:o.containment, installation_method:method,
words:o.circuits_sharing + ' conductor' + (o.circuits_sharing === 1 ? '' : 's') + ' sharing one ' + o.containment + ' run, ' + method.replace(/_/g, ' ') },
table_value_a: table_value_a === undefined ? null : table_value_a, k_ambient:k,
group_factor:null, group_factor_status:'NOT GIVEN', rating_a:null,
design_current_a, verdict:null, reason:'group factor must be typed' };
if (table_value_a === undefined) out.reason = 'no Table A.3 value for ' + o.csa_mm2 + ' mm2 in ' + method.replace(/_/g, ' ');
else if (k === null) out.reason = 'no Table A.4 ambient correction at ' + o.ambient_c + ' C; above 90 C it is refused, not extrapolated';
const gf = o.group_factor;
if (gf !== undefined && gf !== null && out.reason === 'group factor must be typed') {
out.group_factor = gf; out.group_factor_status = 'TYPED';
out.rating_a = Math.round(table_value_a * k * gf * 10) / 10;
out.verdict = out.rating_a >= design_current_a ? 'PASS' : 'FAIL';
out.reason = table_value_a + ' A x ' + k + ' ambient x ' + gf + ' grouping = ' + out.rating_a + ' A against a design current of ' + (Math.round(design_current_a * 100) / 100) + ' A';
}
return out;
}
return { R20, A3, K_AMB, PRESET, BANDS, FARM, FARM_BUILD, LABEL, METHOD, tempFactor, ohmPerKmAt,
segmentConductors, connectorPairs, collect, inputStatus, stringResistance, ampacity };
};
// Family #140693 · element #140693 · 30 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/i0087/cartridges/008700000000-kuiper-programs.js#L388-L395
export const f140693_tubeHullOf = function tubeHullOf(pts){ if (pts.length < 3) return pts.slice();
const p = pts.slice().sort((a, b) => a[0] - b[0] || a[1] - b[1]);
const cr = (o, a, b) => (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]);
const lo = [], up = [];
for (const q of p) { while (lo.length >= 2 && cr(lo[lo.length - 2], lo[lo.length - 1], q) <= 0) lo.pop(); lo.push(q); }
for (let i = p.length - 1; i >= 0; i--) { const q = p[i];
while (up.length >= 2 && cr(up[up.length - 2], up[up.length - 1], q) <= 0) up.pop(); up.push(q); }
lo.pop(); up.pop(); return lo.concat(up); };
// Family #140694 · element #140694 · 30 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/i0087/cartridges/008700000000-kuiper-programs.js#L396-L399
export const f140694_tubeSwell = function tubeSwell(hull, pad){ if (hull.length < 2) return hull;
let mx = 0, my = 0; for (const q of hull) { mx += q[0]; my += q[1]; } mx /= hull.length; my /= hull.length;
return hull.map(q => { const dx = q[0] - mx, dy = q[1] - my, d = Math.max(1e-9, Math.hypot(dx, dy));
return [q[0] + dx / d * pad, q[1] + dy / d * pad]; }); };
// Family #140696 · element #140696 · 30 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/i0087/cartridges/008700000000-kuiper-programs.js#L427-L431
export const f140696_tubeRoute = function tubeRoute(a, b){ const dx = b[0] - a[0], dy = b[1] - a[1];
const ax = Math.abs(dx), ay = Math.abs(dy);
if (ax < 1e-9 || ay < 1e-9 || Math.abs(ax - ay) < 1e-9) return [a, b];
const d = Math.min(ax, ay), sx = Math.sign(dx), sy = Math.sign(dy);
return [a, [a[0] + sx * d, a[1] + sy * d], b]; };
// Family #140876 · element #140876 · 19 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/i0088/cartridges/008800000000-kuiper-programs.js#L901-L909
export const f140876_localWords = function localWords(sys){ const o = sys.outgoers || [], all = o.concat(sys.incomers || [], sys.ties || []);
const edge = o.filter(L => L.ends === 'edge-of-map').length;
const guessed = all.filter(L => L.guessed).length;
const bits = [];
if (o.length) bits.push(edge + ' of ' + o.length + ' outgoers end at the edge of the map');
else bits.push('no outgoers are drawn');
bits.push(guessed === 1 ? '1 join is guessed' : guessed + ' joins are guessed');
const miss = (sys.completeness && sys.completeness.missing) || [];
return bits.join('; ') + (miss.length ? '. ' + miss.join('; ') + '.' : '.'); };
// Family #140877 · element #140877 · 19 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/i0088/cartridges/008800000000-kuiper-programs.js#L912-L921
export const f140877_localCut = function localCut(pts, f){ if (f >= 1) return pts.slice();
if (f <= 0) return [];
let total = 0; for (let i = 1; i < pts.length; i++) total += Math.hypot(pts[i][0] - pts[i - 1][0], pts[i][1] - pts[i - 1][1]);
let want = total * f, out = [pts[0]];
for (let i = 1; i < pts.length; i++) { const d = Math.hypot(pts[i][0] - pts[i - 1][0], pts[i][1] - pts[i - 1][1]);
if (want >= d) { out.push(pts[i]); want -= d; continue; }
const u = d > 1e-9 ? want / d : 0;
out.push([pts[i - 1][0] + (pts[i][0] - pts[i - 1][0]) * u, pts[i - 1][1] + (pts[i][1] - pts[i - 1][1]) * u]);
return out; }
return out; };
// Family #140878 · element #140878 · 19 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/i0088/cartridges/008800000000-kuiper-programs.js#L922-L924
export const f140878_localTrim = function localTrim(ctx, s, maxW){ if (ctx.measureText(s).width <= maxW) return s;
let t2 = s; while (t2.length > 3 && ctx.measureText(t2 + '…').width > maxW) t2 = t2.slice(0, -1);
return t2 + '…'; };
// Family #141449 · element #141449 · 27 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/drawing/kuiper-programs.js#L2839-L2841
export const f141449_stringViewWord = function stringViewWord(D){ const c = D && D.g && D.g.c; const v = String((c && c.view) || '').toLowerCase();
if (v === 'macro' || v === 'micro') return v;
return (innerWidth >= 500 && innerWidth < 700) ? 'micro' : 'macro'; };
// Family #80257 · element #80257 · 7 places in 1 repositories · https://github.com/Ventusltd/ventus-grid-engine/blob/ad566356a44e006682e956483d569f31ddbb9630/engine/connection-capacity.js#L56-L62
export const f80257_positive = 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;
};
// Family #130785 · element #130785 · 7 places in 1 repositories · https://github.com/Ventusltd/galaxies-wafers/blob/5814793812add74605660fa821e6a39b8de80588/iterations/01-route-alpha/layers-panel.mjs#L341-L346
export const f130785_segDist2 = function segDist2(px, py, [ax, ay], [bx, by]) {
const dx = bx - ax, dy = by - ay, L = dx * dx + dy * dy;
const t = L ? Math.max(0, Math.min(1, ((px - ax) * dx + (py - ay) * dy) / L)) : 0;
const qx = ax + t * dx - px, qy = ay + t * dy - py;
return qx * qx + qy * qy;
};
// Family #141757 · element #141757 · 17 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/i0092/cartridges/009200000000-kuiper-programs.js#L3844-L3854
export const f141757_final = function final(s, tag) {
return tag.map(function (t) {
if (t === 'grid' || t === 'interface' || t === 'bus') return 0.95;
if (t === 'tx' || t === 'board') return 0.90;
if (t.indexOf('sk') === 0) return 0.85;
if (t === 'inv') return s.over_mppt ? 2 : 1; /* the machine's own input */
if (t.indexOf('sr') === 0) return s.over_volts ? 2 : 1; /* the array's voltage */
if (t.indexOf('dc') === 0) return s.over_string ? 2 : 0.9; /* the string's current */
return 0.55;
});
};
// Family #32398 · element #32398 · 6 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/uk_renewables_pipeline/v9.4/scripts/plugins/projects-v9-4.js#L42-L53
export const f32398_atlasUrlV9_4 = function atlasUrlV9_4(project) {
if (project.geometry_status !== "valid") return "";
const url = new URL("https://globalgrid2050.com/repd_grid_atlasv8/");
url.searchParams.set("repd_ref", project.repd_ref);
url.searchParams.set("project", project.name);
url.searchParams.set("technology", project.technology);
url.searchParams.set("capacity_mw", project.capacity_mw);
url.searchParams.set("latitude", project.latitude);
url.searchParams.set("longitude", project.longitude);
url.searchParams.set("zoom", "12");
return url.href;
};
// Family #132322 · element #132322 · 6 places in 1 repositories · https://github.com/Ventusltd/galaxies-wafers/blob/5814793812add74605660fa821e6a39b8de80588/iterations/21-dark-pixels/layers-panel.mjs#L353-L360
export const f132322_interp = function interp(stops, x) {
if (x <= stops[0][0]) return stops[0][1];
for (let i = 1; i < stops.length; i++) {
const [x1, y1] = stops[i];
if (x <= x1) { const [x0, y0] = stops[i - 1]; return y0 + (y1 - y0) * (x - x0) / (x1 - x0); }
}
return stops[stops.length - 1][1];
};
// Family #141759 · element #141759 · 6 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/i0092/cartridges/009200000000-kuiper-programs.js#L3761-L3948
export const f141759__anonymous_ = function (root) {
var F = root.FIRE; if (!F || !F.register) return;
/* the kind registers itself, the way the file asks a program to */
var K = root.FIRE_SLD_KIND || (root.FIRE_SLD_KIND = {});
K['site'] = 'site';
var BLOCKS_DRAWN = 8; /* columns across the busbar */
var TEETH = 4; /* string GROUPS drawn per block, not strings */
/* THE BINS, read off published datasheets and carried here as numbers.
phi is DERIVED, not assumed: the sheet prints K_Corr = Isc(BNPI)/Isc(STC)
at a BNPI condition whose rear irradiance is 135 W/m2, so
phi = (K_Corr - 1) / 0.135
and it lands near 0.85 on one family and 0.70 on the other. The class ids
are power-bin labels written here; no maker or product is named. */
var BINS = {
'T645': { voc:45.30, isc:18.31, imp:17.23, beta:-0.25, alpha:0.04, kcorr:1.0945, fuse:35, label:'645 W class' },
'T650': { voc:45.50, isc:18.35, imp:17.27, beta:-0.25, alpha:0.04, kcorr:1.0943, fuse:35, label:'650 W class' },
'T655': { voc:45.70, isc:18.40, imp:17.31, beta:-0.25, alpha:0.04, kcorr:1.0946, fuse:35, label:'655 W class' },
'T660': { voc:45.90, isc:18.45, imp:17.35, beta:-0.25, alpha:0.04, kcorr:1.0943, fuse:35, label:'660 W class' },
'T665': { voc:46.10, isc:18.50, imp:17.39, beta:-0.25, alpha:0.04, kcorr:1.0946, fuse:35, label:'665 W class, the top bin a 0 to +5 W tolerance can deliver' },
'W750': { voc:50.53, isc:18.56, imp:17.70, beta:-0.22, alpha:0.04, kcorr:1.1148, fuse:35, label:'750 W class' },
'W755': { voc:50.56, isc:18.59, imp:17.78, beta:-0.22, alpha:0.04, kcorr:1.1151, fuse:35, label:'755 W class' },
'W760': { voc:50.59, isc:18.62, imp:17.85, beta:-0.22, alpha:0.04, kcorr:1.1149, fuse:35, label:'760 W class' },
'W765': { voc:50.62, isc:18.65, imp:17.93, beta:-0.22, alpha:0.04, kcorr:1.1153, fuse:35, label:'765 W class' },
'W770': { voc:50.65, isc:18.68, imp:18.00, beta:-0.22, alpha:0.04, kcorr:1.1151, fuse:35, label:'770 W class' }
};
var BNPI_REAR = 0.135, TABLE_TOP = 25; /* the sheet's own top rear-gain row */
var V_CEIL = 1500; /* equipment rating, not a standards limit */
var STRING_INPUT_A = 20, MPPT_INPUT_A = 40, STRINGS_PER_MPPT = 2, SIZING = 1.25;
function pieces() {
var P = [];
function line(tag, d, x0, y0, x1, y1) {
P.push({ tag:tag, d:d, kind:'line', x0:x0, y0:y0, x1:x1, y1:y1,
len:Math.hypot(x1 - x0, y1 - y0) });
}
function ring(tag, d, cx, cy, r) {
P.push({ tag:tag, d:d, kind:'ring', cx:cx, cy:cy, r:r, len:2 * Math.PI * r });
}
ring('grid', 0, 0, 0.90, 0.07); /* the grid */
line('interface', 0.07, 0, 0.83, 0, 0.70);
ring('tx', 0.14, 0, 0.655, 0.05); /* down to the collection voltage */
ring('tx', 0.24, 0, 0.575, 0.05);
line('board', 0.34, 0, 0.525, 0, 0.455);
line('bus', 0.42, -0.92, 0.425, 0.92, 0.425); /* the collection busbar */
line('bus', 0.42, -0.92, 0.405, 0.92, 0.405);
var n = BLOCKS_DRAWN;
for (var i = 0; i < n; i++) {
var x = n === 1 ? 0 : -0.82 + 1.64 * i / (n - 1);
var d0 = 0.45 + Math.abs(x); /* further out is further along */
var t = 'b' + i;
line(t, d0, x, 0.395, x, 0.315); /* feeder off the busbar */
ring(t, d0 + 0.09, x, 0.275, 0.035); /* the switch */
ring('sk' + i, d0 + 0.16, x, 0.195, 0.042); /* skid transformer, two rings */
ring('sk' + i, d0 + 0.24, x, 0.118, 0.042);
line(t, d0 + 0.31, x, 0.070, x, 0.030);
ring('inv', d0 + 0.36, x, -0.015, 0.045); /* the inverter, a symbol */
line('dc' + i, d0 + 0.44, x, -0.062, x, -0.150); /* the DC it eats */
var w = 0.072;
line('dc' + i, d0 + 0.50, x - w, -0.150, x + w, -0.150);
/* THE TEETH ARE NOT TAGGED 'pv', AND THAT IS NOT A NAMING WHIM.
sldLayout decides which pieces are SYMBOLS - pieces given a floor of
dots so they read as the thing they are - with a PREFIX match:
t.startsWith('pv'). That was written when a network drawing had one
solar symbol on it. Tagging 32 comb pieces 'pv' claimed 32 symbol
floors, which is 704 of the 896 dots the whole drawing gets, and the
rounding loop cannot take a symbol below its floor. The collection
busbar - the spine of the picture - was left with scraps and did not
appear at all. The blocks hung off nothing. */
for (var j = 0; j < TEETH; j++) { /* teeth are GROUPS of strings */
var tx = x - w + 2 * w * j / (TEETH - 1);
line('sr' + i, d0 + 0.54, tx, -0.150, tx, -0.300);
ring('sr' + i, d0 + 0.62, tx, -0.340, 0.020);
}
}
return P;
}
/* brightness per tag: 0..1 lit, 2 = outside a rating (amber), -1 = dark */
function final(s, tag) {
return tag.map(function (t) {
if (t === 'grid' || t === 'interface' || t === 'bus') return 0.95;
if (t === 'tx' || t === 'board') return 0.90;
if (t.indexOf('sk') === 0) return 0.85;
if (t === 'inv') return s.over_mppt ? 2 : 1; /* the machine's own input */
if (t.indexOf('sr') === 0) return s.over_volts ? 2 : 1; /* the array's voltage */
if (t.indexOf('dc') === 0) return s.over_string ? 2 : 0.9; /* the string's current */
return 0.55;
});
}
var BOXES = [
{ key:'module_class', label:'module class', kind:'choice',
choices:Object.keys(BINS).map(function (k) { return [k, BINS[k].label]; }) },
{ key:'modules_in_series', label:'modules in series', unit:'',
kind:'number', min:20, max:34, step:1 },
{ key:'rear_gain_pct', label:'rear gain', unit:'%',
kind:'number', min:0, max:30, step:1 },
{ key:'site_min_c', label:'assessment temperature', unit:'C',
kind:'number', min:-20, max:0, step:1 },
{ key:'routing', label:'string routing', kind:'choice',
choices:[['leapfrog', 'leapfrog, go and return alongside each other'],
['one-after-another', 'one after another, return down the row']] }
];
F.register('site', 'SITE', function (inputs) {
var id = inputs.module_class && BINS[inputs.module_class] ? inputs.module_class : 'T660';
var b = BINS[id];
var se = inputs.modules_in_series === undefined ? 30 : +inputs.modules_in_series;
var rear = (inputs.rear_gain_pct === undefined ? BNPI_REAR * 100 : +inputs.rear_gain_pct) / 100;
var tmin = inputs.site_min_c === undefined ? -10 : +inputs.site_min_c;
var routing = inputs.routing || 'leapfrog';
var phi = (b.kcorr - 1) / BNPI_REAR;
var kb = 1 + phi * rear; /* rear side adds current */
var kt = 1 + b.alpha / 100 * (tmin - 25); /* cold takes a little back */
var isc_e = b.isc * kb * kt, imp_e = b.imp * kb * kt;
var v = se * b.voc * (1 + b.beta / 100 * (tmin - 25));
/* THREE DIFFERENT TESTS, AND THE SIZING FACTOR BELONGS TO ONLY ONE OF THEM.
An earlier draft multiplied the machine's own input limit by 1.25 and so
failed designs that are inside it. 1.25 is a continuous-current factor
for array cable and overcurrent protection; a manufacturer's input limit
is a limit on the current itself. They are reported separately. */
var over_volts = v > V_CEIL; /* equipment rating */
var over_string = imp_e > STRING_INPUT_A; /* string input, working current */
var over_mppt = isc_e * STRINGS_PER_MPPT > MPPT_INPUT_A; /* the machine's input */
var design_a = SIZING * isc_e; /* what cable and OCPD are sized to */
var over_fuse = design_a > b.fuse; /* the sheet's max series fuse */
var s = { over_volts:over_volts, over_string:over_string, over_mppt:over_mppt };
var head = V_CEIL - v;
var said =
'The whole plant in one drawing: grid, interface, one transformer to the '
+ 'collection busbar, and ' + BLOCKS_DRAWN + ' blocks hanging off it. '
+ se + ' of the ' + b.label + ' in series reaches ' + v.toFixed(1)
+ ' V at ' + tmin + ' C, '
+ (over_volts ? 'OVER the ' + V_CEIL + ' V equipment rating by '
+ (-head).toFixed(1) + ' V'
: 'inside the ' + V_CEIL + ' V rating by ' + head.toFixed(1) + ' V')
+ (!over_volts && head < 25 ? ' - which at a 0 to +5 W tolerance is not a margin, '
+ 'because the module that arrives can be the top bin' : '')
+ '. At ' + (rear * 100).toFixed(1) + '% rear gain, with a bifaciality of '
+ phi.toFixed(3) + ' taken from this sheet\'s own published row, the string '
+ 'works at ' + imp_e.toFixed(2) + ' A and shorts at ' + isc_e.toFixed(2) + ' A: '
+ (over_string ? 'OVER the ' + STRING_INPUT_A + ' A string input'
: 'inside the ' + STRING_INPUT_A + ' A string input') + ', '
+ (over_mppt ? 'OVER the ' + MPPT_INPUT_A + ' A machine input on ' + STRINGS_PER_MPPT
+ ' strings' : 'inside the ' + MPPT_INPUT_A + ' A machine input') + ', '
+ 'and cable and protection size to ' + design_a.toFixed(2) + ' A against a '
+ b.fuse + ' A maximum series fuse'
+ (over_fuse ? ' - OVER it' : '')