In this section
- Standalone geodesy · stars / library/standalone.mjs lines 6840–7539
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 6840–7539 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
- f138208__anonymous_, rnd, LAYOUT_WORDS, build, extraAfter, rowOf0, turned, x0, ptAt, minusPt, minus, inRow, run, run, f138709_round3, f136848_searchCommands, f137321_stringPieces, line, ring, f137403_stringWires, add, f137452__anonymous_, rnd, build, turned, minus, run, f137551__anonymous_, rnd, build
- 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:6840-7539 · 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
{ key:'box_spacing_m', label:'junction boxes apart', unit:'m', kind:'number', min:0.05, 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 };
};
// Family #138208 · element #138208 · 32 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/i0073/cartridges/006500000000-kuiper-programs.js#L562-L836
export const f138208__anonymous_ = function (root) {
const F = root.FIRE; if (!F) return;
const R20 = { 2.5: 8.21, 4: 5.09, 6: 3.39, 10: 1.95 }; // milliohm per metre at 20 C, tinned copper, class 5
const DEF = { modules: 30, width_m: 1.303, module_height_m: 2.384, cell_cols: 6, cell_rows: 22, module_vmp: 38.1, module_voc: 45.9,
// THE TABLE ITSELF. One module high in portrait on a fixed tilt is the old row, exactly.
mounting: 'fixed', orientation: 'portrait', modules_high: 1, routing: '', view: 'wiring', sheet: 0,
// A RETURN TIER IS MOUNTED THE OTHER WAY ROUND, and that is not a detail. Going back along
// the upper row, the + box of one module has to reach the - box of the one to its LEFT, so
// the link is a pitch PLUS the box spacing instead of a pitch minus it: 2.16 m where 0.48 m
// was expected. Turning every module in the return rows end for end puts it back to 0.48 m,
// and that is what is actually done on a table. It is an input because it is a decision.
turn_alternate_rows: 0,
// A JUMPER IS WHAT IS REALLY DONE when two leads do not meet: a short cable is made up on
// site and spliced between them, which closes the circuit and costs cable and one more
// mated pair at that link. Without this the model says the string is open, which is the
// truth about the LEADS and not about the finished job. Off by default, because a jumper
// is a decision somebody has to take and pay for.
jumpers: 0,
gap_up_m: 0.02, ridge_gap_m: 0.15, tube_gap_m: 0.12,
gap_m: 0.02, box_spacing_m: 0.84, wiring: 'leapfrog', turn_every_second: 0,
lead_plus_m: null, lead_minus_m: null, lead_mm2: 4, cable_mm2: 6, near_end_m: 59, amps: 17.35,
// TWO CONDUCTORS IN TWO PLACES AT TWO TEMPERATURES. A module lead is clipped to the back of a
// module in the sun; the site cable is in a tray or a trench. One figure for both was always a
// simplification, and it flattered whichever of the two was hotter. conductor_c is kept as the
// NAME FOR BOTH: give it and both take it, so every command ever written still means what it
// said, and equal temperatures reproduce the old model to the digit.
conductor_c: null, t_lead_c: 80, t_site_c: 55, rating_c: 90,
// HOW FAR APART THE TWO HOME RUNS ARE LAID. The array's own loop is one thing; the pair of
// cables running back to the inverter is another, and on a long home run it is the bigger of
// the two. It has NO DEFAULT, on purpose: nobody can know from a drawing whether that pair
// was bundled or run in two trays, and the difference moves the answer more than the wiring
// choice does. Until it is given, the home run loop and the total are NOT REPORTED. A model
// that guesses a number like that is worse than a model that says it does not know.
home_separation_m: null,
// SLACK AT EVERY LINK. A lead is not a straight line: it is clipped, it drops and it comes
// back. The distance a link has to span is the straight distance between the two boxes PLUS
// whatever allowance the installer is told to leave. Zero is the geometric case.
slack_m: 0,
contact_milliohm: 0.35, return_offset_m: 0.3, lead_gap_m: 0.05 };
const rnd = (x, n) => { const k = Math.pow(10, n); return Math.round(x * k) / k; };
const ROUTE_WORDS = { 'one-after-another':'one after another, with a cable to bring the far end home',
'serpentine':'along and back, out along one row and back along the next',
'leapfrog':'leapfrog inside each row', 'zigzag':'zigzag between two rows' };
const LAYOUT_WORDS = g => { const o = g.port ? 'portrait' : 'landscape';
const m = g.mount === 'east-west' ? 'east and west facing, ' + g.high + ' in ' + o + ' on each face'
: g.mount === 'tracker' ? 'a tracker, ' + g.rows + ' in ' + o
: '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';
if (c.lead_plus_m === null) c.lead_plus_m = leap ? 0.84 : 0.35;
if (c.lead_minus_m === null) c.lead_minus_m = leap ? 1.89 : 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);
const pair = c.lead_plus_m + c.lead_minus_m, 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);
const reaches = pair + 1e-9 >= need;
links.push({ from, to, need, reaches, jumper: !reaches && !!c.jumpers ? need - pair : 0,
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 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),
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:'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 };
};
// Family #138709 · element #138709 · 31 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/i0073/cartridges/006900000000-kuiper-programs.js#L2137-L2146
export const f138709_round3 = (pp, r2) => { if (pp.length < 3) return pp.slice(); const out = [pp[0]];
for (let i2 = 1; i2 + 1 < pp.length; i2++) { const a2 = pp[i2 - 1], b2 = pp[i2], c2 = pp[i2 + 1];
const u1 = [a2[0] - b2[0], a2[1] - b2[1]], u2 = [c2[0] - b2[0], c2[1] - b2[1]];
const L1 = Math.max(1e-6, Math.hypot(u1[0], u1[1])), L2 = Math.max(1e-6, Math.hypot(u2[0], u2[1]));
const k1 = Math.min(r2, L1 * 0.45), k2 = Math.min(r2, L2 * 0.45);
const s1 = [b2[0] + u1[0] / L1 * k1, b2[1] + u1[1] / L1 * k1], s2 = [b2[0] + u2[0] / L2 * k2, b2[1] + u2[1] / L2 * k2];
out.push(s1); for (let q = 1; q < 5; q++) { const t2 = q / 5, w2 = (1 - t2) * (1 - t2), mm = 2 * (1 - t2) * t2, e2 = t2 * t2;
out.push([w2 * s1[0] + mm * b2[0] + e2 * s2[0], w2 * s1[1] + mm * b2[1] + e2 * s2[1]]); }
out.push(s2); }
out.push(pp[pp.length - 1]); return out; };
// Family #136848 · element #136848 · 16 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/i0073/cartridges/004600000000-kuiper-programs.js#L598-L611
export const f136848_searchCommands = function searchCommands(commands, text) {
const words = String(text === undefined || text === null ? '' : text).toLowerCase().split(/\s+/).filter(Boolean);
const out = [];
if (!Array.isArray(commands)) return out;
for (let i = 0; i < commands.length && out.length < 50; i++) {
const c = commands[i];
if (!c) continue;
const hay = ((c.family || '') + ' ' + (c.kind || '') + ' ' + (c.sentence || '')).toLowerCase();
let all = true;
for (let w = 0; w < words.length; w++) if (hay.indexOf(words[w]) < 0) { all = false; break; }
if (all) out.push(c);
}
return out;
};
// Family #137321 · element #137321 · 16 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/i0073/cartridges/005500000000-kuiper-programs.js#L1320-L1339
export const f137321_stringPieces = function stringPieces(g){
const P = [], W = 1.9, X = m => -0.95 + W * m / g.row, yb = 0;
const line = (tag, d, x0, y0, x1, y1) => { const len = Math.hypot(x1 - x0, y1 - y0); if (len > 1e-6) P.push({ tag, d, kind:'line', x0, y0, x1, y1, len }); };
const ring = (tag, d, cx, cy, r) => P.push({ tag, d, kind:'ring', cx, cy, r, len:2 * Math.PI * r });
ring('inv', 0, -1.13, yb, 0.055);
const first = g.order[0], last = g.order[g.order.length - 1];
line('home', 0.06, -1.075, yb + 0.02, X(g.minus(first)), yb + 0.02);
line('mod', 0.1, -0.95, yb - 0.06, 0.95, yb - 0.06);
for (let k = 1; k <= g.N; k++) { const x = X((k - 1) * g.pitch); line('mod', 0.1, x, yb - 0.06, x, yb + 0.06); }
line('mod', 0.1, 0.95, yb - 0.06, 0.95, yb + 0.06);
const step = 1 / (g.links.length + 2);
for (let k = 1; k <= g.N; k++) { const at = g.order.indexOf(k) * step + 0.1; ring('box', at, X(g.minus(k)), yb, 0.009); ring('box', at, X(g.plus(k)), yb, 0.009); }
g.links.forEach((l, i) => { const xa = X(l.x_from), xb = X(l.x_to), tag = (l.reaches ? 'ok' : 'short') + i, d = 0.1 + (i + 1) * step, span = Math.abs(xb - xa);
if (!g.leap) { line(tag, d, xa, yb, xb, yb); return; }
const h = (l.back ? -1 : 1) * (l.back ? 0.30 + 0.9 * span : 0.22 + 0.9 * span), s = Math.sign(xb - xa) * Math.min(span * 0.28, 0.03);
line(tag, d, xa, yb + Math.sign(h) * 0.012, xa + s, yb + h); line(tag, d, xa + s, yb + h, xb - s, yb + h); line(tag, d, xb - s, yb + h, xb, yb + Math.sign(h) * 0.012); });
if (g.leap) line('home', 1.15, X(g.plus(last)), yb - 0.02, -1.075, yb - 0.02);
else { const xe = X(g.plus(last)); line('ret', 1.15, 0.0, yb - 0.40, -1.10, yb - 0.40); line('ret', 1.12, xe, yb - 0.40, 0.0, yb - 0.40); line('ret', 1.1, xe, yb - 0.012, xe, yb - 0.40); line('ret', 1.2, -1.10, yb - 0.40, -1.10, yb - 0.05); }
return P;
};
// Family #137403 · element #137403 · 16 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/i0073/cartridges/005600000000-kuiper-programs.js#L1335-L1351
export const f137403_stringWires = function stringWires(g){
const W = 1.9, X = m => -0.95 + W * m / g.row, yb = 0, wires = [];
const first = g.order[0], last = g.order[g.order.length - 1];
const add = (tag, pol, segs, link) => wires.push({ tag, pol, segs, link:link || null });
add('home', 'minus', [[-1.075, yb + 0.02, X(g.minus(first)), yb + 0.02, 0.06]]);
const step = 1 / (g.links.length + 2);
g.links.forEach((l, i) => { const xa = X(l.x_from), xb = X(l.x_to), tag = (l.reaches ? 'ok' : 'short') + i, d = 0.1 + (i + 1) * step, span = Math.abs(xb - xa);
if (!g.leap) { add(tag, 'link', [[xa, yb, xb, yb, d]], l); return; }
const h = (l.back ? -1 : 1) * (l.back ? 0.30 + 0.9 * span : 0.22 + 0.9 * span), s = Math.sign(xb - xa) * Math.min(span * 0.28, 0.03);
add(tag, 'link', [[xa, yb + Math.sign(h) * 0.012, xa + s, yb + h, d], [xa + s, yb + h, xb - s, yb + h, d],
[xb - s, yb + h, xb, yb + Math.sign(h) * 0.012, d]], l); });
if (g.leap) add('home', 'plus', [[X(g.plus(last)), yb - 0.02, -1.075, yb - 0.02, 1.15]]);
else { const xe = X(g.plus(last));
add('ret', 'plus', [[xe, yb - 0.012, xe, yb - 0.40, 1.10], [xe, yb - 0.40, 0.0, yb - 0.40, 1.12],
[0.0, yb - 0.40, -1.10, yb - 0.40, 1.15], [-1.10, yb - 0.40, -1.10, yb - 0.05, 1.20]]); }
return { wires, X, yb };
};
// Family #137452 · element #137452 · 16 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/i0073/cartridges/005700000000-kuiper-programs.js#L549-L603
export const f137452__anonymous_ = function (root) {
const F = root.FIRE; if (!F) return;
const R20 = { 2.5: 8.21, 4: 5.09, 6: 3.39, 10: 1.95 }; // milliohm per metre at 20 C, tinned copper, class 5
const DEF = { modules: 30, width_m: 1.303, module_height_m: 2.384, cell_cols: 6, cell_rows: 22, module_vmp: 38.1,
gap_m: 0.02, box_spacing_m: 0.84, wiring: 'leapfrog', turn_every_second: 0,
lead_plus_m: null, lead_minus_m: null, lead_mm2: 4, cable_mm2: 6, near_end_m: 59, amps: 17.35, conductor_c: 70,
contact_milliohm: 0.35, return_offset_m: 0.3, lead_gap_m: 0.05 };
const rnd = (x, n) => { const k = Math.pow(10, n); return Math.round(x * k) / k; };
function build(inp) {
const c = Object.assign({}, DEF, inp || {}), N = Math.max(2, Math.min(40, Math.round(c.modules))), pitch = c.width_m + c.gap_m, a = (c.width_m - c.box_spacing_m) / 2;
const leap = String(c.wiring).toLowerCase() !== 'sequential';
if (c.lead_plus_m === null) c.lead_plus_m = leap ? 0.84 : 0.35;
if (c.lead_minus_m === null) c.lead_minus_m = leap ? 1.89 : 0.28;
const turned = k => !!c.turn_every_second && k % 2 === 0, x0 = k => (k - 1) * pitch;
const minus = k => x0(k) + a + (turned(k) ? c.box_spacing_m : 0), plus = k => x0(k) + a + (turned(k) ? 0 : c.box_spacing_m);
const order = []; if (leap) { for (let k = 1; k <= N; k += 2) order.push(k); for (let k = (N % 2 ? N - 1 : N); k >= 2; k -= 2) order.push(k); } else for (let k = 1; k <= N; k++) order.push(k);
const pair = c.lead_plus_m + c.lead_minus_m, links = [];
for (let i = 0; i + 1 < order.length; i++) { const from = order[i], to = order[i + 1], need = Math.abs(plus(from) - minus(to));
links.push({ from, to, need, reaches: pair + 1e-9 >= need, back: to < from, x_from: plus(from), x_to: minus(to) }); }
const last = order[order.length - 1], row = N * pitch, ret = leap ? 0 : plus(last), f = 1 + 0.00393 * (c.conductor_c - 20);
const lead_m = N * pair, field_m = 2 * c.near_end_m + minus(order[0]) + (leap ? plus(last) : 0) + ret;
const pairs = links.length + 2 + (leap ? 0 : 1);
const ohm = ((R20[c.lead_mm2] || 5.09) * lead_m + (R20[c.cable_mm2] || 3.39) * field_m) / 1000 * f + pairs * c.contact_milliohm / 1000;
const short = links.filter(l => !l.reaches), needs = links.map(l => l.need);
const loop = leap ? row * c.lead_gap_m : row * c.return_offset_m;
return { c, N, pitch, a, leap, order, links, row, pair, lead_m, field_m, pairs, ohm, short, needs, loop, minus, plus, 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 = (g.leap ? 'Leapfrog' : 'Sequential') + (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;
const order = g.order.map(k => 'M' + k).join(' → ');
const said = name + ': ' + g.N + ' modules, ' + 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; '
+ (open ? 'THE CIRCUIT IS OPEN: ' + g.short.length + ' links do not reach (short by up to ' + worst.toFixed(2) + ' m), so this string carries no current at all'
: '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; ' + g.ohm.toFixed(3) + ' ohm, ' + (amps * amps * g.ohm).toFixed(0) + ' W lost at ' + amps + ' A';
return { numbers: { circuit: open ? 'OPEN' : 'closed', current_a: rnd(amps, 2), 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),
volts_to_earth_each_end: '−' + rnd(g.N * c.module_vmp / 2, 0) + ' to +' + rnd(g.N * c.module_vmp / 2, 0),
enclosed_loop_area_m2_rough: rnd(g.loop, 1) },
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 at ' + c.conductor_c + ' C; near end ' + c.near_end_m + ' m from the inverter; the enclosed loop is row length x a stated gap, rough, and is what a nearby stroke couples into. '
+ 'Electrical order ' + order + '. A floating array sits about symmetric around earth, so the two ends are about minus and plus half the string voltage to earth. '
+ 'Every input can be changed. An estimate, not a study.', string: g };
}
F.register('string', 'STRINGS', run);
F.string = { build, DEF };
};
// Family #137551 · element #137551 · 16 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/i0073/cartridges/005800000000-kuiper-programs.js#L555-L643
export const f137551__anonymous_ = function (root) {
const F = root.FIRE; if (!F) return;
const R20 = { 2.5: 8.21, 4: 5.09, 6: 3.39, 10: 1.95 }; // milliohm per metre at 20 C, tinned copper, class 5
const DEF = { modules: 30, width_m: 1.303, module_height_m: 2.384, cell_cols: 6, cell_rows: 22, module_vmp: 38.1, module_voc: 45.9,
gap_m: 0.02, box_spacing_m: 0.84, wiring: 'leapfrog', turn_every_second: 0,
lead_plus_m: null, lead_minus_m: null, lead_mm2: 4, cable_mm2: 6, near_end_m: 59, amps: 17.35, conductor_c: 70,
contact_milliohm: 0.35, return_offset_m: 0.3, lead_gap_m: 0.05 };
const rnd = (x, n) => { const k = Math.pow(10, n); return Math.round(x * k) / k; };
function build(inp) {
const c = Object.assign({}, DEF, inp || {}), N = Math.max(2, Math.min(40, Math.round(c.modules))), pitch = c.width_m + c.gap_m, a = (c.width_m - c.box_spacing_m) / 2;
const leap = String(c.wiring).toLowerCase() !== 'sequential';
if (c.lead_plus_m === null) c.lead_plus_m = leap ? 0.84 : 0.35;
if (c.lead_minus_m === null) c.lead_minus_m = leap ? 1.89 : 0.28;
const turned = k => !!c.turn_every_second && k % 2 === 0, x0 = k => (k - 1) * pitch;
const minus = k => x0(k) + a + (turned(k) ? c.box_spacing_m : 0), plus = k => x0(k) + a + (turned(k) ? 0 : c.box_spacing_m);
const order = []; if (leap) { for (let k = 1; k <= N; k += 2) order.push(k); for (let k = (N % 2 ? N - 1 : N); k >= 2; k -= 2) order.push(k); } else for (let k = 1; k <= N; k++) order.push(k);
const pair = c.lead_plus_m + c.lead_minus_m, links = [];
for (let i = 0; i + 1 < order.length; i++) { const from = order[i], to = order[i + 1], need = Math.abs(plus(from) - minus(to));
links.push({ from, to, need, reaches: pair + 1e-9 >= need, back: to < from, x_from: plus(from), x_to: minus(to) }); }
const last = order[order.length - 1], row = N * pitch, ret = leap ? 0 : plus(last), f = 1 + 0.00393 * (c.conductor_c - 20);
const lead_m = N * pair, field_m = 2 * c.near_end_m + minus(order[0]) + (leap ? plus(last) : 0) + ret;
const pairs = links.length + 2 + (leap ? 0 : 1);
const ohm = ((R20[c.lead_mm2] || 5.09) * lead_m + (R20[c.cable_mm2] || 3.39) * field_m) / 1000 * f + pairs * c.contact_milliohm / 1000;
const short = links.filter(l => !l.reaches), needs = links.map(l => l.need);
const loop = leap ? row * c.lead_gap_m : row * c.return_offset_m;
return { c, N, pitch, a, leap, order, links, row, pair, lead_m, field_m, pairs, ohm, short, needs, loop, minus, plus, 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 = (g.leap ? 'Leapfrog' : 'Sequential') + (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 said = name + ': ' + g.N + ' modules, ' + 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; '
+ (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; ' + g.ohm.toFixed(3) + ' ohm, ' + (amps * amps * g.ohm).toFixed(0) + ' W lost at ' + amps + ' A';
return { 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),
volts_to_earth_each_end: '−' + rnd(g.N * c.module_vmp / 2, 0) + ' to +' + rnd(g.N * c.module_vmp / 2, 0),
enclosed_loop_area_m2_rough: rnd(g.loop, 1) },
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 at ' + c.conductor_c + ' C; near end ' + c.near_end_m + ' m from the inverter; the enclosed loop is row length x a stated gap, rough, and is what a nearby stroke couples into. '
+ '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 sweep round the loop is the INSTANT OF CLOSURE; in steady direct current 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:'wiring', label:'wiring', kind:'choice', choices:[['leapfrog', 'leapfrog'], ['sequential', 'one after another']] },
{ 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 between modules', unit:'m', kind:'number', min:0, max:1, step:0.005 },
{ key:'box_spacing_m', label:'junction boxes apart', unit:'m', kind:'number', min:0.05, 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:'conductor_c', label:'conductor temperature', unit:'C', kind:'number', min:-25, max:120, step:1 },
{ 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 };
};
// Family #137656 · element #137656 · 16 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/i0073/cartridges/005900000000-kuiper-programs.js#L555-L646
export const f137656__anonymous_ = function (root) {
const F = root.FIRE; if (!F) return;
const R20 = { 2.5: 8.21, 4: 5.09, 6: 3.39, 10: 1.95 }; // milliohm per metre at 20 C, tinned copper, class 5
const DEF = { modules: 30, width_m: 1.303, module_height_m: 2.384, cell_cols: 6, cell_rows: 22, module_vmp: 38.1, module_voc: 45.9,
gap_m: 0.02, box_spacing_m: 0.84, wiring: 'leapfrog', turn_every_second: 0,
lead_plus_m: null, lead_minus_m: null, lead_mm2: 4, cable_mm2: 6, near_end_m: 59, amps: 17.35, conductor_c: 70,
contact_milliohm: 0.35, return_offset_m: 0.3, lead_gap_m: 0.05 };
const rnd = (x, n) => { const k = Math.pow(10, n); return Math.round(x * k) / k; };
function build(inp) {
const c = Object.assign({}, DEF, inp || {}), N = Math.max(2, Math.min(40, Math.round(c.modules))), pitch = c.width_m + c.gap_m, a = (c.width_m - c.box_spacing_m) / 2;
const leap = String(c.wiring).toLowerCase() !== 'sequential';
if (c.lead_plus_m === null) c.lead_plus_m = leap ? 0.84 : 0.35;
if (c.lead_minus_m === null) c.lead_minus_m = leap ? 1.89 : 0.28;
const turned = k => !!c.turn_every_second && k % 2 === 0, x0 = k => (k - 1) * pitch;
const minus = k => x0(k) + a + (turned(k) ? c.box_spacing_m : 0), plus = k => x0(k) + a + (turned(k) ? 0 : c.box_spacing_m);
const order = []; if (leap) { for (let k = 1; k <= N; k += 2) order.push(k); for (let k = (N % 2 ? N - 1 : N); k >= 2; k -= 2) order.push(k); } else for (let k = 1; k <= N; k++) order.push(k);
const pair = c.lead_plus_m + c.lead_minus_m, links = [];
for (let i = 0; i + 1 < order.length; i++) { const from = order[i], to = order[i + 1], need = Math.abs(plus(from) - minus(to));
links.push({ from, to, need, reaches: pair + 1e-9 >= need, back: to < from, x_from: plus(from), x_to: minus(to) }); }
const last = order[order.length - 1], row = N * pitch, ret = leap ? 0 : plus(last), f = 1 + 0.00393 * (c.conductor_c - 20);
const lead_m = N * pair, field_m = 2 * c.near_end_m + minus(order[0]) + (leap ? plus(last) : 0) + ret;
const pairs = links.length + 2 + (leap ? 0 : 1);
const ohm = ((R20[c.lead_mm2] || 5.09) * lead_m + (R20[c.cable_mm2] || 3.39) * field_m) / 1000 * f + pairs * c.contact_milliohm / 1000;
const short = links.filter(l => !l.reaches), needs = links.map(l => l.need);
const loop = leap ? row * c.lead_gap_m : row * c.return_offset_m;
return { c, N, pitch, a, leap, order, links, row, pair, lead_m, field_m, pairs, ohm, short, needs, loop, minus, plus, 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 = (g.leap ? 'Leapfrog' : 'Sequential') + (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 said = name + ': ' + g.N + ' modules, ' + 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; '
+ (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; '
+ (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');
return { 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),
enclosed_loop_area_m2_rough: rnd(g.loop, 1) },
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 at ' + c.conductor_c + ' C; near end ' + c.near_end_m + ' m from the inverter; the enclosed loop is row length x a stated gap, rough, and is what a nearby stroke couples into. '
+ '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 sweep round the loop is the INSTANT OF CLOSURE; in steady direct current 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:'wiring', label:'wiring', kind:'choice', choices:[['leapfrog', 'leapfrog'], ['sequential', 'one after another']] },
{ 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 between modules', unit:'m', kind:'number', min:0, max:1, step:0.005 },
{ key:'box_spacing_m', label:'junction boxes apart', unit:'m', kind:'number', min:0.05, 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:'conductor_c', label:'conductor temperature', unit:'C', kind:'number', min:-25, max:120, step:1 },
{ 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 };
};
// Family #137761 · element #137761 · 16 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/i0073/cartridges/006000000000-kuiper-programs.js#L555-L704
export const f137761__anonymous_ = function (root) {
const F = root.FIRE; if (!F) return;
const R20 = { 2.5: 8.21, 4: 5.09, 6: 3.39, 10: 1.95 }; // milliohm per metre at 20 C, tinned copper, class 5
const DEF = { modules: 30, width_m: 1.303, module_height_m: 2.384, cell_cols: 6, cell_rows: 22, module_vmp: 38.1, module_voc: 45.9,
gap_m: 0.02, box_spacing_m: 0.84, wiring: 'leapfrog', turn_every_second: 0,
lead_plus_m: null, lead_minus_m: null, lead_mm2: 4, cable_mm2: 6, near_end_m: 59, amps: 17.35,
// TWO CONDUCTORS IN TWO PLACES AT TWO TEMPERATURES. A module lead is clipped to the back of a
// module in the sun; the site cable is in a tray or a trench. One figure for both was always a
// simplification, and it flattered whichever of the two was hotter. conductor_c is kept as the
// NAME FOR BOTH: give it and both take it, so every command ever written still means what it
// said, and equal temperatures reproduce the old model to the digit.
conductor_c: null, t_lead_c: 80, t_site_c: 55, rating_c: 90,
// HOW FAR APART THE TWO HOME RUNS ARE LAID. The array's own loop is one thing; the pair of
// cables running back to the inverter is another, and on a long home run it is the bigger of
// the two. It has NO DEFAULT, on purpose: nobody can know from a drawing whether that pair
// was bundled or run in two trays, and the difference moves the answer more than the wiring
// choice does. Until it is given, the home run loop and the total are NOT REPORTED. A model
// that guesses a number like that is worse than a model that says it does not know.
home_separation_m: null,
// SLACK AT EVERY LINK. A lead is not a straight line: it is clipped, it drops and it comes
// back. The distance a link has to span is the straight distance between the two boxes PLUS
// whatever allowance the installer is told to leave. Zero is the geometric case.
slack_m: 0,
contact_milliohm: 0.35, return_offset_m: 0.3, lead_gap_m: 0.05 };
const rnd = (x, n) => { const k = Math.pow(10, n); return Math.round(x * k) / k; };
function build(inp) {
const c = Object.assign({}, DEF, inp || {}), N = Math.max(2, Math.min(40, Math.round(c.modules))), pitch = c.width_m + c.gap_m, a = (c.width_m - c.box_spacing_m) / 2;
const leap = String(c.wiring).toLowerCase() !== 'sequential';
if (c.lead_plus_m === null) c.lead_plus_m = leap ? 0.84 : 0.35;
if (c.lead_minus_m === null) c.lead_minus_m = leap ? 1.89 : 0.28;
const turned = k => !!c.turn_every_second && k % 2 === 0, x0 = k => (k - 1) * pitch;
const minus = k => x0(k) + a + (turned(k) ? c.box_spacing_m : 0), plus = k => x0(k) + a + (turned(k) ? 0 : c.box_spacing_m);
const order = []; if (leap) { for (let k = 1; k <= N; k += 2) order.push(k); for (let k = (N % 2 ? N - 1 : N); k >= 2; k -= 2) order.push(k); } else for (let k = 1; k <= N; k++) order.push(k);
const pair = c.lead_plus_m + c.lead_minus_m, links = [];
for (let i = 0; i + 1 < order.length; i++) { const from = order[i], to = order[i + 1], need = Math.abs(plus(from) - minus(to)) + (+c.slack_m || 0);
links.push({ from, to, need, reaches: pair + 1e-9 >= need, back: to < from, x_from: plus(from), x_to: minus(to) }); }
const last = order[order.length - 1], row = N * pitch, ret = leap ? 0 : plus(last);
// 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);
const lead_m = N * pair, field_m = 2 * c.near_end_m + minus(order[0]) + (leap ? plus(last) : 0) + ret;
const pairs = links.length + 2 + (leap ? 0 : 1);
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), 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 = leap ? 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 saved = !leap ? 0 : (N - 2) * pitch + (c.turn_every_second ? c.box_spacing_m : 0);
return { c, N, pitch, a, leap, order, links, row, pair, lead_m, field_m, pairs, ohm, ohmLead, ohmSite,
short, needs, loop, arrayLoop, homeLoop, sep, saved, hot, fLead, fSite, minus, plus, 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 = (g.leap ? 'Leapfrog' : 'Sequential') + (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, ' + 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; '
+ (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; '