GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Cables and conductors / globalgrid2050 / testcode/wafer-development-environment/202609190330-cable-cross-sections

Conductor and 3 more files

A web page in the testcode folder of GlobalGrid2050 that draws on a canvas (units: mm², °C, Ω), covering cables, using IEC 60228 and ISO 128. Published at https://globalgrid2050.com/testcode/wafer-development-environment/202609191345-proof-7/conductor.html.

626 lines of HTML and CSS from globalgrid2050, in 4 files. Topic: Cables and conductors. Section 31 of 2044.

Cut 2026-12-06T03:07:51+00:00. A copy for reading; the repository at the stated commit is the source.

In the State lines below, domain stage, users and canonical status are rule-based first approximations from code and path evidence (rules explore-agent-rules-v1), not observed facts: the rules.

In this section

  1. Wafer Development Environment — Cable Cross Sections Style Sheet render · globalgrid2050 / testcode/wafer-development-environment/202609190330-cable-cross-sections/style.css lines 1–182
  2. Conductor electrical · globalgrid2050 / testcode/wafer-development-environment/202609191315-proof-4/conductor.html lines 1–110
  3. Conductor electrical · globalgrid2050 / testcode/wafer-development-environment/202609191335-proof-6/conductor.html lines 1–151
  4. Conductor electrical · globalgrid2050 / testcode/wafer-development-environment/202609191345-proof-7/conductor.html lines 1–183

Wafer Development Environment — Cable Cross Sections Style Sheet

A style sheet in the testcode folder of GlobalGrid2050. Served with the page at https://globalgrid2050.com/testcode/wafer-development-environment/202609190330-cable-cross-sections/.

renderglobalgrid2050 / testcode/wafer-development-environment/202609190330-cable-cross-sections/style.css · lines 1–182 of 182 · version 2026-09-19 03:30 · Entry point

What it does
Side effects: changes the web page (DOM).
Why it exists in the grid workflow
Domain stage experimental (path word 'testcode'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
Downstream impact
Used directly by 1 file: Wafer Development Environment — Cable Cross Sections Page (globalgrid2050, https://globalgrid2050.com/testcode/wafer-development-environment/202609190330-cable-cross-sections/). Reached from 88 other entry points, including GlobalGrid2050 Historical Builds (globalgrid2050, https://globalgrid2050.com/historical_builds.html); GlobalGrid2050 Homepage Before Four Nests (globalgrid2050, https://globalgrid2050.com/homepage-before-four-nests-20260925.html); Homepage V037 (globalgrid2050, https://globalgrid2050.com/homepage_versions/homepage_v037.html). It is itself an entry point, published at https://globalgrid2050.com/testcode/wafer-development-environment/202609190330-cable-cross-sections/.
What it achieves
Designed at 430 px first; the desktop is the same layout with more room.
Why it matters
Loaded by the Cable Cross Sections page at https://globalgrid2050.com/testcode/wafer-development-environment/202609190330-cable-cross-sections/.
Application
globalgrid2050 · testcode/wafer-development-environment/202609190330-cable-cross-sections · style sheet
Uses
none found
Used by
loaded by Wafer Development Environment — Cable Cross Sections Page (stylesheet)
Produces
none declared
Defines here
none
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 testcode/wafer-development-environment/202609190330-cable-cross-sections/style.css:1-182 · blob 48c3965f8e20a068ff77a938df2b864ba097ce56 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: experimental · users: none · canonical: production_core
/* The Line Wafer. Designed at 430 px first; the desktop is the same layout with
   more room. One canvas, three chrome strips, nothing that scrolls the page. */

:root{
  --ink:#d8dee9; --dim:#8b93a7; --ground:#0b0d12; --edge:#1b2030;
  --lit:#ffd54a; --beam:#5ec8f2;
  --top:env(safe-area-inset-top,0px); --bot:env(safe-area-inset-bottom,0px);
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0; background:var(--ground); color:var(--ink);
  font:13px/1.45 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
  overflow:hidden; overscroll-behavior:none; -webkit-text-size-adjust:100%;
}
#stage{position:fixed; inset:0; width:100%; height:100%; display:block; touch-action:none}

#bar{
  position:fixed; left:0; right:0; top:0; z-index:2;
  display:flex; gap:.75rem; align-items:baseline; flex-wrap:wrap;
  padding:calc(var(--top) + .5rem) .75rem .5rem;
  background:linear-gradient(#0b0d12ee,#0b0d1200); pointer-events:none;
}
#wordmark{letter-spacing:.14em; font-size:11px; order:2; flex:0 0 auto}
.dim{color:var(--dim)}

/* ── the menu bar ─────────────────────────────────────────────────────────
   The idiom is GridAtlas's, taken from atlas/modules/202609031958-menu-bar.js
   in the gridatlas repository: one thin row at the very top, tiny uppercase
   titles on the left, the wordmark in the middle, and every control behind a
   panel that is hidden at rest — what that module calls closed_at_rest. The
   wafer had fifteen preset buttons in two rows printed across the belt. They
   are all still here; they are summoned now instead of displayed, and the
   drawing gets the frame. */
#bar{align-items:center; flex-wrap:nowrap; gap:.5rem; padding:calc(var(--top) + .3rem) .6rem .3rem}
#count{order:3; flex:1 1 0; min-width:0; text-align:right; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
#menubar{order:1; flex:1 1 0; min-width:0; display:flex; align-items:stretch; pointer-events:auto}
.gm-menu{position:relative; min-width:0}
.gm-title{appearance:none; border:0; background:transparent; color:var(--dim); cursor:pointer;
  font:10px/1 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; letter-spacing:.12em;
  text-transform:uppercase; padding:7px 8px; min-height:26px; border-radius:4px}
.gm-title:hover,.gm-title:focus-visible,.gm-menu.gm-open>.gm-title{background:rgba(94,200,242,.16); color:var(--ink); outline:none}
.gm-panel{position:absolute; top:100%; left:0; z-index:22; min-width:min(32rem,88vw); max-width:92vw;
  max-height:64vh; overflow:auto; display:flex; flex-direction:column;
  background:#0b0e14f7; border:1px solid var(--edge); border-radius:0 0 6px 6px; padding:4px}
.gm-panel[hidden]{display:none!important}
.gm-panel button{display:flex; justify-content:space-between; gap:1.2rem; align-items:baseline;
  text-align:left; background:transparent; border:0; color:var(--ink); cursor:pointer;
  font:11px/1.55 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; padding:6px 8px; border-radius:4px}
.gm-panel button:hover,.gm-panel button:focus-visible{background:rgba(94,200,242,.14); outline:none}
.gm-panel code{flex:0 0 auto; color:#5b6377; font:inherit; white-space:nowrap}
@media (max-width:640px){
  #hud{display:none}
  #wordmark{font-size:10px}
  .gm-title{padding:7px 5px; font-size:9px; letter-spacing:.04em}
  .gm-panel{position:fixed; top:2.4rem; left:4px; right:4px; min-width:0; max-width:none; border-radius:6px}
  .gm-panel button span{overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
}

#beam{
  position:fixed; z-index:3; left:.5rem; right:.5rem;
  bottom:calc(var(--bot) + 3.4rem);
  display:flex; gap:.4rem;
}
#beam input{
  flex:1 1 0; min-width:0; padding:.6rem .55rem;
  background:#11151f; color:var(--ink); border:1px solid var(--edge); border-radius:6px;
  font:inherit; font-size:16px; /* 16px stops iOS zooming the page on focus */
}
#beam input:focus{outline:none; border-color:var(--beam)}
#beam button{
  flex:0 0 auto; padding:.6rem .9rem; border-radius:6px; cursor:pointer;
  background:#11151f; color:var(--beam); border:1px solid var(--beam);
  font:inherit; font-size:13px; letter-spacing:.1em;
}
#beam button:active{background:#16202c}

/* The card is a guest on top of the drawing, and it behaves like one. It opens
   in the top corner rather than across the belt, it carries nothing but the
   code, and it is a small window: drag it by its title bar (mouse, pen or
   finger), fold it to the bar, throw it wide, close it. Its z-index is above
   the command bar and the log, because the two of them used to print over the
   code and the code is the thing being read. */
#panel{
  position:fixed; z-index:21; left:auto; bottom:auto;
  right:.5rem; top:calc(var(--top) + 5.4rem);
  width:min(30rem, calc(100vw - 1rem));
  max-height:44vh; overflow:hidden;
  background:#0e121bf2; border:1px solid var(--edge); border-radius:8px;
  padding:0; display:flex; flex-direction:column;
}
#panel.max{left:.5rem; right:.5rem; top:calc(var(--top) + 3rem); bottom:calc(var(--bot) + 4rem);
  width:auto; max-height:none; height:auto}
#panel[hidden]{display:none!important}
#panelbar{
  display:flex; align-items:center; gap:.3rem; flex:0 0 auto;
  padding:.25rem .3rem .25rem .7rem; border-bottom:1px solid var(--edge);
  background:#11151f; border-radius:7px 7px 0 0;
  cursor:move; user-select:none; -webkit-user-select:none; touch-action:none;
  font-size:11px; color:var(--dim); letter-spacing:.06em; text-transform:uppercase;
}
#paneltitle{flex:1 1 auto; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
#panelbar button{
  flex:0 0 auto; width:2rem; height:1.9rem; padding:0; cursor:pointer;
  background:#0b0e15; color:var(--ink); border:1px solid var(--edge); border-radius:4px;
  font:inherit; font-size:13px; text-transform:none;
}
#panelbar button:hover,#panelbar button:focus-visible{border-color:var(--beam); outline:none}
#panelbody{padding:.75rem .8rem 1rem; overflow:auto; -webkit-overflow-scrolling:touch; flex:1 1 auto; min-height:0}
#panel.min{max-height:none; height:auto}
#panel.min #panelbody{display:none}
#panel h2{margin:0 .5rem .5rem 0; font-size:15px; font-weight:600; letter-spacing:.02em}
#panel h2 .n{color:var(--lit)}
#panel dl{display:grid; grid-template-columns:auto 1fr; gap:.15rem .6rem; margin:.5rem 0}
#panel dt{color:var(--dim)}
#panel dd{margin:0; overflow-wrap:anywhere}
#panel p{margin:.5rem 0 0}
#panel ul{margin:.35rem 0 0; padding-left:1.1rem}
#panel li{margin:.15rem 0}
.fam{color:var(--beam)}
.refuse{color:var(--lit)}

#foot{
  position:fixed; z-index:2; left:0; right:0; bottom:0;
  display:flex; gap:.15rem; flex-direction:column;
  padding:.35rem .75rem calc(var(--bot) + .35rem);
  background:linear-gradient(#0b0d1200,#0b0d12ee); pointer-events:none;
  font-size:10.5px;
}
#hint{text-align:left}
#foot a{color:var(--beam); pointer-events:auto; text-decoration:underline}

@media (min-width:760px){
  #beam{left:auto; right:1rem; width:26rem; bottom:calc(var(--bot) + 2.9rem)}
  #foot{flex-direction:row; gap:.6rem; justify-content:space-between}
  #hint{text-align:right}
  #panel{left:auto; right:1rem; top:calc(var(--top) + 4.4rem); bottom:auto; width:30rem; max-height:52vh; resize:both; overflow:auto; min-width:20rem; min-height:7rem; max-width:94vw}
  #foot{font-size:11px}
}
/* ── reading the code ───────────────────────────────────────────────────── */
/* ── reading the code ─────────────────────────────────────────────────────
   The line and the block are the only places in this page where the estate's
   own text appears. Everything else is drawn from numbers; this is fetched,
   one row at a time, and it is set apart so you can always tell which is
   which. */
.code{margin:.4rem 0 .6rem;padding:.45rem .55rem;background:#0b0e15;border:1px solid #1b2030;border-left:2px solid #5ec8f2;
      border-radius:4px;font:12px/1.45 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;color:#cfe3f2;
      white-space:pre-wrap;overflow-wrap:anywhere;max-height:14rem;overflow:auto}
.code.loading{color:#8b93a7;border-left-color:#1b2030;font-style:italic}
.code.refuse{color:#f2b05e;border-left-color:#f2b05e;white-space:normal;font-style:normal}

/* ── the line, with the ten lines either side of it ───────────────────────
   Context is never written here from a guess. Every row below is a row of the
   real file at the commit the key records, fetched at the moment it is shown,
   and it is only drawn once the file's own line agrees with the numbered row.
   When it cannot be fetched or it disagrees, the card says so and shows the
   one line it can prove. */
.code{white-space:pre;overflow-wrap:normal;max-height:16rem}
.code .row{display:block}
.code .row .ln{display:inline-block;width:4.6em;text-align:right;padding-right:.9em;color:#5b6377;user-select:none}
.code .row.hit{background:#1b2030;color:var(--lit)}
.code .row.hit .ln{color:var(--lit)}
.ctxnote{margin:.1rem 0 .6rem;font-size:11px;color:var(--dim)}
.ctxnote.refuse{color:var(--lit)}
.srclink{display:inline-block;margin:.1rem 0 .4rem;font-size:11px;color:var(--beam)}
.code[data-empty="1"]::after{content:"an empty line";color:#5b6377;font-style:italic}

.famopen{display:block;width:100%;text-align:left;background:none;border:0;padding:.2rem 0;color:inherit;font:inherit;cursor:pointer}
.famopen:hover .fam{text-decoration:underline}
.famopen.open .fam::before{content:"▾ "}
.famopen:not(.open) .fam::before{content:"▸ "}

.famblock{margin:.3rem 0 .6rem}
.famhead{font-size:11px;letter-spacing:.04em;color:#e7ebf3;margin:.2rem 0}
ol.block{list-style:none;margin:.2rem 0;padding:0;border:1px solid #1b2030;border-radius:4px;overflow:hidden}
ol.block li+li{border-top:1px solid #141925}
.blockline{display:flex;gap:.5rem;width:100%;text-align:left;background:#0b0e15;border:0;padding:.22rem .45rem;
           color:#cfe3f2;font:12px/1.45 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;cursor:pointer}
.blockline:hover{background:#121826}
.blockline .n{flex:0 0 4.5rem;color:#5b6377;text-align:right;user-select:none}
.blockline code{white-space:pre-wrap;overflow-wrap:anywhere}
#storeline{font-size:10.5px;margin:.5rem 0 0}

Conductor

A web page in the testcode folder of GlobalGrid2050 that draws on a canvas (units: mm²), covering cables, using IEC 60228 and ISO 128. Published at https://globalgrid2050.com/testcode/wafer-development-environment/202609191315-proof-4/conductor.html.

electricalglobalgrid2050 / testcode/wafer-development-environment/202609191315-proof-4/conductor.html · lines 1–110 of 110 · version 2026-09-19 13:15 · Entry point · pattern hatch (shared by 9 files)

What it does
It draws cables. Defines geometry, hatch, dim, draw. Side effects: changes the web page (DOM).
Why it exists in the grid workflow
Domain stage experimental (path word 'testcode'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow. Domain terms in the code: cables.
Inputs & outputs
Out: web page; canvas drawing.
Downstream impact
It is itself an entry point, published at https://globalgrid2050.com/testcode/wafer-development-environment/202609191315-proof-4/conductor.html.
What it achieves
It is built from the draw step (`draw`). Defines `geometry`, `hatch`, `dim` and 1 more. It responds to resize events.
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
globalgrid2050 · testcode/wafer-development-environment/202609191315-proof-4 · page
Uses
none found
Used by
mentioned in Standalone (comment link)
Produces
geometry, hatch, dim, draw
Defines here
geometry, hatch, dim, draw
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 testcode/wafer-development-environment/202609191315-proof-4/conductor.html:1-110 · blob ff93af12796b087c709408d517f9f8ef117a07ef · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: experimental · users: none · canonical: production_core
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Conductor section</title>
<style>
  :root{--bg:#090c13;--ink:#d5dcea;--dim:#7d8799;--cy:#2ee6e6;--gn:#22ee77;--am:#ffb000;--mg:#ff2bd6}
  *{box-sizing:border-box} html,body{margin:0;height:100%;background:var(--bg);color:var(--ink);
    font:12px/1.55 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;overflow:hidden}
  canvas{position:fixed;inset:0;width:100%;height:100%}
  #bar{position:fixed;top:0;left:0;right:0;display:flex;gap:8px;align-items:center;padding:8px 12px;z-index:5;
    background:#090c13ee;border-bottom:1px solid #12414a;flex-wrap:wrap}
  #bar b{color:var(--cy);letter-spacing:.16em;text-transform:uppercase;margin-right:10px}
  button{background:#0b1a20;color:#8fb3bd;border:1px solid #12414a;padding:6px 10px;font:inherit;cursor:pointer;text-transform:uppercase;letter-spacing:.06em}
  button.on,button:hover{border-color:var(--cy);color:var(--cy)}
  #foot{position:fixed;left:0;right:0;bottom:0;padding:7px 12px;color:var(--dim);border-top:1px solid #12414a;background:#090c13ee;z-index:5}
</style>
</head>
<body>
<canvas id="c"></canvas>
<div id="bar"><b>Conductor section</b><span id="btns"></span></div>
<div id="foot">a section, not a design &middot; every dimension is derived from the stated inputs or marked CANDIDATE &middot; materials are told apart
  by hatch, as on a drawing, so colour stays free to mean state &middot; no material image is shown because no real, attributed image is held:
  a texture made to look like metal would be a lie &middot; provided as is, without warranty of any kind</div>
<script type="module">
// A CONDUCTOR, DRAWN FROM ARITHMETIC. A concentric stranded conductor is the hexagonal law made of
// metal: one wire, then a layer of 6, then 12, then 18, layer k holding 6k wires on a circle of
// radius k x d. So the wire count of n layers is 3n^2 + 3n + 1 = 1, 7, 19, 37, 61, 91, which is why
// IEC 60228 class 2 strandings are those numbers, and the overall diameter is (2n+1) x d.
// Everything drawn below follows from a nominal area and a wire count. Nothing is traced from a
// photograph and nothing is decorated.
const CASES = [
  { id:'al400', name:'400 mm² aluminium · class 2 · 61 wires', area:400, n:61, metal:'Al', layers:4, lay:'concentric',
    compactFill:0.90, note:'Circular compacted. Compaction deforms the round wires so the same metal fits a smaller circle.' },
  { id:'cu6c5', name:'6 mm² tinned copper · class 5 · 84 × 0.30', area:6, n:84, d:0.30, metal:'Cu-Sn', lay:'bunched',
    note:'Flexible, as used in H1Z2Z2-K solar cable. Bunched wires have NO fixed positions: this arrangement is an idealisation.' },
  { id:'cu6c6', name:'6 mm² copper · class 6 · 189 × 0.20', area:6, n:189, d:0.20, metal:'Cu', lay:'bunched',
    note:'Extra flexible. Finer wire, more of them, same metal. Bunched: an idealisation, as above.' }
];
const cv = document.getElementById('c'), g = cv.getContext('2d'); let cur = CASES[0];
const btns = document.getElementById('btns');
CASES.forEach(c => { const b = document.createElement('button'); b.textContent = c.id; b.onclick = () => { cur = c; draw(); }; c.btn = b; btns.appendChild(b); });

function geometry(c){
  const o = { wires:[] };
  if (c.lay === 'concentric') {
    o.d = Math.sqrt(4*c.area / (c.n*Math.PI));                 // from A = n x pi d^2 / 4
    o.D = (2*c.layers + 1) * o.d;                              // across the layers
    o.wires.push([0,0]);
    for (let k = 1; k <= c.layers; k++) for (let j = 0; j < 6*k; j++) { const a = 2*Math.PI*j/(6*k) + (k%2 ? 0 : Math.PI/(6*k));
      o.wires.push([k*o.d*Math.cos(a), k*o.d*Math.sin(a)]); }
    o.fill = c.n*o.d*o.d / (o.D*o.D);                          // metal area over circle area
    o.Dc = Math.sqrt(4*c.area / (Math.PI*c.compactFill));      // the circle the same metal needs at the compacted fill
    o.metalArea = c.n*Math.PI*o.d*o.d/4;
  } else {
    o.d = c.d; o.metalArea = c.n*Math.PI*o.d*o.d/4; o.fill = 0.75; o.D = o.d*Math.sqrt(c.n/o.fill);
    for (let i = 0; i < c.n; i++) { const r = (o.D/2 - o.d/2)*Math.sqrt((i+0.5)/c.n), a = i*2.399963229728653; o.wires.push([r*Math.cos(a), r*Math.sin(a)]); }
  }
  return o;
}
function hatch(x, y, r, metal){                                  // ISO 128 style: material by hatch, not by colour
  g.save(); g.beginPath(); g.arc(x, y, r, 0, 6.2832); g.clip(); g.strokeStyle = 'rgba(201,211,230,.55)'; g.lineWidth = 1;
  const step = Math.max(3, r/3.2), ang = metal === 'Al' ? Math.PI/4 : -Math.PI/4;
  for (let t = -2*r; t <= 2*r; t += step) { g.beginPath(); g.moveTo(x + t - 2*r*Math.cos(ang), y - 2*r*Math.sin(ang)); g.lineTo(x + t + 2*r*Math.cos(ang), y + 2*r*Math.sin(ang)); g.stroke(); }
  if (metal === 'Cu-Sn') { g.strokeStyle = 'rgba(201,211,230,.9)'; g.lineWidth = Math.max(1, r*0.16); g.beginPath(); g.arc(x, y, r*0.92, 0, 6.2832); g.stroke(); }
  g.restore();
}
function dim(x1, x2, y, label, colour){
  g.strokeStyle = colour; g.fillStyle = colour; g.lineWidth = 1; g.beginPath();
  g.moveTo(x1, y-7); g.lineTo(x1, y+7); g.moveTo(x2, y-7); g.lineTo(x2, y+7); g.moveTo(x1, y); g.lineTo(x2, y); g.stroke();
  g.textAlign = 'center'; g.fillText(label, (x1+x2)/2, y - 8); g.textAlign = 'start';
}
function draw(){
  cv.width = innerWidth; cv.height = innerHeight; CASES.forEach(c => c.btn.className = c === cur ? 'on' : '');
  const o = geometry(cur), W = cv.width, H = cv.height, cx = W*0.40, cy = H*0.52, S = Math.min(W*0.62, H*0.70) / (o.D*1.12), R = o.D/2*S;
  g.fillStyle = '#090c13'; g.fillRect(0,0,W,H); g.font = '12px ui-monospace,Consolas,monospace';
  for (const [x,y] of o.wires) { const px = cx + x*S, py = cy - y*S, r = o.d/2*S;
    hatch(px, py, r, cur.metal); g.strokeStyle = '#c9d3e6'; g.lineWidth = 1.2; g.beginPath(); g.arc(px, py, r, 0, 6.2832); g.stroke(); }
  g.strokeStyle = 'rgba(46,230,230,.55)'; g.setLineDash([6,5]); g.beginPath(); g.arc(cx, cy, R, 0, 6.2832); g.stroke(); g.setLineDash([]);
  dim(cx - R, cx + R, cy + R + 34, 'Ø ' + o.D.toFixed(2) + ' mm  across the ' + (cur.lay === 'concentric' ? 'round wires, (2n+1) × d' : 'bundle, idealised'), '#2ee6e6');
  if (o.Dc) { g.strokeStyle = '#ffb000'; g.lineWidth = 1.6; g.beginPath(); g.arc(cx, cy, o.Dc/2*S, 0, 6.2832); g.stroke();
    dim(cx - o.Dc/2*S, cx + o.Dc/2*S, cy + R + 66, 'Ø ' + o.Dc.toFixed(2) + ' mm  after compaction to fill ' + cur.compactFill.toFixed(2) + '  (CANDIDATE input)', '#ffb000'); }
  const w0 = o.wires[o.wires.length-1]; dim(cx + w0[0]*S - o.d/2*S, cx + w0[0]*S + o.d/2*S, cy - w0[1]*S - o.d/2*S - 12, 'd ' + o.d.toFixed(3) + ' mm', '#ff2bd6');
  // the title block, as on a drawing
  const bx = W*0.70, by = 70, L = [];
  L.push(['TITLE', cur.name]); L.push(['STANDARD', 'IEC 60228, conductors of insulated cables']);
  L.push(['NOMINAL AREA', cur.area + ' mm²  (input)']); L.push(['WIRES', cur.n + (cur.lay === 'concentric' ? '  = 3n²+3n+1, n = ' + cur.layers + '  (derived)' : '  (input)')]);
  L.push(['WIRE DIAMETER', o.d.toFixed(3) + ' mm  ' + (cur.lay === 'concentric' ? '(derived from area and count)' : '(input; CANDIDATE against the standard)')]);
  L.push(['METAL AREA', o.metalArea.toFixed(2) + ' mm²  (derived)']);
  L.push(['FILL, ROUND WIRES', cur.lay === 'concentric' ? cur.n + '/' + Math.pow(2*cur.layers+1,2) + ' = ' + o.fill.toFixed(3) + '  (derived, exact)' : o.fill.toFixed(2) + '  (assumed; CANDIDATE)']);
  if (o.Dc) L.push(['DIAMETER SAVED', (o.D - o.Dc).toFixed(2) + ' mm, ' + ((1 - o.Dc/o.D)*100).toFixed(1) + '%  by compaction']);
  L.push(['LAY', cur.lay]); L.push(['HATCH', cur.metal === 'Al' ? 'aluminium, 45°' : (cur.metal === 'Cu-Sn' ? 'copper, 135°, tin as a heavy rim' : 'copper, 135°')]);
  g.strokeStyle = '#12414a'; g.strokeRect(bx - 12, by - 22, W - bx, L.length*30 + 70);
  L.forEach(([k, v], i) => { g.fillStyle = '#2ee6e6'; g.fillText(k, bx, by + i*30); g.fillStyle = /CANDIDATE/.test(v) ? '#ffb000' : '#d5dcea'; g.fillText(v, bx, by + i*30 + 14); });
  g.fillStyle = '#8fb3bd'; const words = cur.note.split(' '); let line = '', yy = by + L.length*30 + 8;
  for (const w of words) { if (g.measureText(line + w).width > W - bx - 30) { g.fillText(line, bx, yy); yy += 16; line = ''; } line += w + ' '; } g.fillText(line, bx, yy);
  // the drawing checks itself
  const ring = []; if (cur.lay === 'concentric') for (let k = 1; k <= cur.layers; k++) ring.push(6*k);
  window.__selftest = { id:cur.id, wires_drawn:o.wires.length, wires_declared:cur.n, T1_count_matches:o.wires.length === cur.n,
    T2_layers_are_6k: cur.lay !== 'concentric' || ring.reduce((a,b)=>a+b,1) === cur.n, layers:ring,
    T3_metal_area_equals_nominal: cur.lay !== 'concentric' || Math.abs(o.metalArea - cur.area) < 1e-9,
    fill:+o.fill.toFixed(4), D_mm:+o.D.toFixed(3), Dc_mm:o.Dc ? +o.Dc.toFixed(3) : null, d_mm:+o.d.toFixed(4) };
  window.__selftest.PASS = window.__selftest.T1_count_matches && window.__selftest.T2_layers_are_6k && window.__selftest.T3_metal_area_equals_nominal;
  document.title = 'conductor ' + cur.id + ' selftest ' + (window.__selftest.PASS ? 'PASS' : 'FAIL');
}
addEventListener('resize', draw); draw();
</script>
</body>
</html>

Conductor

A web page in the testcode folder of GlobalGrid2050 that draws on a canvas (units: mm²), covering cables, using IEC 60228 and ISO 128. Published at https://globalgrid2050.com/testcode/wafer-development-environment/202609191335-proof-6/conductor.html.

electricalglobalgrid2050 / testcode/wafer-development-environment/202609191335-proof-6/conductor.html · lines 1–151 of 151 · version 2026-09-19 13:35 · Entry point · pattern hatch (shared by 9 files)

What it does
It draws cables. Defines geometry, hatch, dim, draw. Side effects: changes the web page (DOM).
Why it exists in the grid workflow
Domain stage experimental (path word 'testcode'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow. Domain terms in the code: cables.
Inputs & outputs
Out: web page; canvas drawing.
Downstream impact
It is itself an entry point, published at https://globalgrid2050.com/testcode/wafer-development-environment/202609191335-proof-6/conductor.html.
What it achieves
It is built from the draw step (`draw`). Defines `geometry`, `hatch`, `dim` and 1 more. It responds to resize events.
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
globalgrid2050 · testcode/wafer-development-environment/202609191335-proof-6 · page
Uses
none found
Used by
none found
Produces
geometry, hatch, dim, draw
Defines here
geometry, hatch, dim, draw
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 testcode/wafer-development-environment/202609191335-proof-6/conductor.html:1-151 · blob a0869153d002a737092f261b7fd136c76e40f0fe · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: experimental · users: none · canonical: production_core
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Conductor section</title>
<style>
  :root{--bg:#090c13;--ink:#d5dcea;--dim:#7d8799;--cy:#2ee6e6;--gn:#22ee77;--am:#ffb000;--mg:#ff2bd6}
  *{box-sizing:border-box} html,body{margin:0;height:100%;background:var(--bg);color:var(--ink);
    font:12px/1.55 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;overflow:hidden}
  canvas{position:fixed;inset:0;width:100%;height:100%;touch-action:none}
  #bar{position:fixed;top:0;left:0;right:0;display:flex;gap:8px;align-items:center;padding:8px 12px;z-index:5;
    background:#090c13ee;border-bottom:1px solid #12414a;flex-wrap:wrap}
  #bar b{color:var(--cy);letter-spacing:.16em;text-transform:uppercase;margin-right:10px}
  button{background:#0b1a20;color:#8fb3bd;border:1px solid #12414a;padding:6px 10px;font:inherit;cursor:pointer;text-transform:uppercase;letter-spacing:.06em}
  button.on,button:hover{border-color:var(--cy);color:var(--cy)}
  #foot{position:fixed;left:0;right:0;bottom:0;padding:7px 12px;color:var(--dim);border-top:1px solid #12414a;background:#090c13ee;z-index:5}
  /* THE PHONE. On a narrow screen the title block cannot stand beside the section, so the drawing
     takes the upper part of the clear band and the block is set out beneath it (see draw()). The
     buttons grow to a thumb's size and the footnote collapses rather than taking half the screen. */
  @media (max-width:760px){
    html,body{font-size:11px}
    #bar{padding:6px 8px} #bar b{margin-right:6px}
    button{padding:9px 11px}
    #foot{padding:6px 8px;max-height:22vh;overflow:auto}
  }
</style>
</head>
<body>
<canvas id="c"></canvas>
<div id="bar"><b>Conductor section</b><span id="btns"></span></div>
<div id="foot">a section, not a design &middot; every dimension is derived from the stated inputs or marked CANDIDATE &middot; materials are told apart
  by hatch, as on a drawing, so colour stays free to mean state &middot; no material image is shown because no real, attributed image is held:
  a texture made to look like metal would be a lie &middot; provided as is, without warranty of any kind</div>
<script type="module">
// A CONDUCTOR, DRAWN FROM ARITHMETIC. A concentric stranded conductor is the hexagonal law made of
// metal: one wire, then a layer of 6, then 12, then 18, layer k holding 6k wires on a circle of
// radius k x d. So the wire count of n layers is 3n^2 + 3n + 1 = 1, 7, 19, 37, 61, 91, which is why
// IEC 60228 class 2 strandings are those numbers, and the overall diameter is (2n+1) x d.
// Everything drawn below follows from a nominal area and a wire count. Nothing is traced from a
// photograph and nothing is decorated.
const CASES = [
  { id:'al400', name:'400 mm² aluminium · class 2 · 61 wires', area:400, n:61, metal:'Al', layers:4, lay:'concentric',
    compactFill:0.90, note:'Circular compacted. Compaction deforms the round wires so the same metal fits a smaller circle.' },
  { id:'cu6c5', name:'6 mm² tinned copper · class 5 · 84 × 0.30', area:6, n:84, d:0.30, metal:'Cu-Sn', lay:'bunched',
    note:'Flexible, as used in H1Z2Z2-K solar cable. Bunched wires have NO fixed positions: this arrangement is an idealisation.' },
  { id:'cu6c6', name:'6 mm² copper · class 6 · 189 × 0.20', area:6, n:189, d:0.20, metal:'Cu', lay:'bunched',
    note:'Extra flexible. Finer wire, more of them, same metal. Bunched: an idealisation, as above.' }
];
const cv = document.getElementById('c'), g = cv.getContext('2d'); let cur = CASES[0];
const btns = document.getElementById('btns');
CASES.forEach(c => { const b = document.createElement('button'); b.textContent = c.id; b.onclick = () => { cur = c; draw(); }; c.btn = b; btns.appendChild(b); });

function geometry(c){
  const o = { wires:[] };
  if (c.lay === 'concentric') {
    o.d = Math.sqrt(4*c.area / (c.n*Math.PI));                 // from A = n x pi d^2 / 4
    o.D = (2*c.layers + 1) * o.d;                              // across the layers
    o.wires.push([0,0]);
    for (let k = 1; k <= c.layers; k++) for (let j = 0; j < 6*k; j++) { const a = 2*Math.PI*j/(6*k) + (k%2 ? 0 : Math.PI/(6*k));
      o.wires.push([k*o.d*Math.cos(a), k*o.d*Math.sin(a)]); }
    o.fill = c.n*o.d*o.d / (o.D*o.D);                          // metal area over circle area
    o.Dc = Math.sqrt(4*c.area / (Math.PI*c.compactFill));      // the circle the same metal needs at the compacted fill
    o.metalArea = c.n*Math.PI*o.d*o.d/4;
  } else {
    o.d = c.d; o.metalArea = c.n*Math.PI*o.d*o.d/4; o.fill = 0.75; o.D = o.d*Math.sqrt(c.n/o.fill);
    for (let i = 0; i < c.n; i++) { const r = (o.D/2 - o.d/2)*Math.sqrt((i+0.5)/c.n), a = i*2.399963229728653; o.wires.push([r*Math.cos(a), r*Math.sin(a)]); }
  }
  return o;
}
function hatch(x, y, r, metal){                                  // ISO 128 style: material by hatch, not by colour
  g.save(); g.beginPath(); g.arc(x, y, r, 0, 6.2832); g.clip(); g.strokeStyle = 'rgba(201,211,230,.55)'; g.lineWidth = 1;
  const step = Math.max(3, r/3.2), ang = metal === 'Al' ? Math.PI/4 : -Math.PI/4;
  for (let t = -2*r; t <= 2*r; t += step) { g.beginPath(); g.moveTo(x + t - 2*r*Math.cos(ang), y - 2*r*Math.sin(ang)); g.lineTo(x + t + 2*r*Math.cos(ang), y + 2*r*Math.sin(ang)); g.stroke(); }
  if (metal === 'Cu-Sn') { g.strokeStyle = 'rgba(201,211,230,.9)'; g.lineWidth = Math.max(1, r*0.16); g.beginPath(); g.arc(x, y, r*0.92, 0, 6.2832); g.stroke(); }
  g.restore();
}
function dim(x1, x2, y, label, colour){
  g.strokeStyle = colour; g.fillStyle = colour; g.lineWidth = 1; g.beginPath();
  g.moveTo(x1, y-7); g.lineTo(x1, y+7); g.moveTo(x2, y-7); g.lineTo(x2, y+7); g.moveTo(x1, y); g.lineTo(x2, y); g.stroke();
  g.textAlign = 'center'; g.fillText(label, (x1+x2)/2, y - 8); g.textAlign = 'start';
}
function draw(){
  cv.width = innerWidth; cv.height = innerHeight; CASES.forEach(c => c.btn.className = c === cur ? 'on' : '');
  // THE CLEAR BAND. The bar and the footnote are fixed, so the drawing is fitted to what is left of
  // the window, measured, not guessed. Narrow: the section on top, the title block underneath.
  const barH = document.getElementById('bar').getBoundingClientRect().height;
  const footH = document.getElementById('foot').getBoundingClientRect().height;
  const W = cv.width, H = cv.height, top = barH + 10, bot = H - footH - 10, band = Math.max(60, bot - top);
  const narrow = W < 760;
  const o = geometry(cur);
  // The title block's height is known before a word of it is written: it has a fixed number of
  // rows. On a narrow screen it is reserved first and the section is given what is left, so the
  // block can never be pushed off the bottom of the screen by a larger drawing.
  const rows = 9 + (o.Dc ? 1 : 0), lh = narrow ? 22 : 30;
  const blockH = narrow ? rows*lh + 62 + 46 : 0;                    // rows, the frame, three lines of note
  const avail = narrow ? Math.max(120, band - blockH - 12) : band;
  const cx = narrow ? W*0.50 : W*0.40;
  const R = narrow ? Math.min(W*0.40, (avail - 84)/2) : o.D/2 * (Math.min(W*0.62, band*0.86) / (o.D*1.12));
  const S = 2*R/o.D;
  const cy = narrow ? top + 10 + R : top + band*0.52;
  g.fillStyle = '#090c13'; g.fillRect(0,0,W,H); g.font = '12px ui-monospace,Consolas,monospace';
  for (const [x,y] of o.wires) { const px = cx + x*S, py = cy - y*S, r = o.d/2*S;
    hatch(px, py, r, cur.metal); g.strokeStyle = '#c9d3e6'; g.lineWidth = 1.2; g.beginPath(); g.arc(px, py, r, 0, 6.2832); g.stroke(); }
  g.strokeStyle = 'rgba(46,230,230,.55)'; g.setLineDash([6,5]); g.beginPath(); g.arc(cx, cy, R, 0, 6.2832); g.stroke(); g.setLineDash([]);
  dim(cx - R, cx + R, cy + R + 34, 'Ø ' + o.D.toFixed(2) + ' mm  across the ' + (cur.lay === 'concentric' ? 'round wires, (2n+1) × d' : 'bundle, idealised'), '#2ee6e6');
  if (o.Dc) { g.strokeStyle = '#ffb000'; g.lineWidth = 1.6; g.beginPath(); g.arc(cx, cy, o.Dc/2*S, 0, 6.2832); g.stroke();
    dim(cx - o.Dc/2*S, cx + o.Dc/2*S, cy + R + 66, 'Ø ' + o.Dc.toFixed(2) + ' mm  after compaction to fill ' + cur.compactFill.toFixed(2) + '  (CANDIDATE input)', '#ffb000'); }
  const w0 = o.wires[o.wires.length-1]; dim(cx + w0[0]*S - o.d/2*S, cx + w0[0]*S + o.d/2*S, cy - w0[1]*S - o.d/2*S - 12, 'd ' + o.d.toFixed(3) + ' mm', '#ff2bd6');
  // the title block, as on a drawing
  const bx = narrow ? 14 : W*0.70, by = narrow ? Math.round(top + avail + 34) : top + 24;
  const bw = narrow ? W - 28 : W - bx, L = [];
  L.push(['TITLE', cur.name]); L.push(['STANDARD', 'IEC 60228, conductors of insulated cables']);
  L.push(['NOMINAL AREA', cur.area + ' mm²  (input)']); L.push(['WIRES', cur.n + (cur.lay === 'concentric' ? '  = 3n²+3n+1, n = ' + cur.layers + '  (derived)' : '  (input)')]);
  L.push(['WIRE DIAMETER', o.d.toFixed(3) + ' mm  ' + (cur.lay === 'concentric' ? '(derived from area and count)' : '(input; CANDIDATE against the standard)')]);
  L.push(['METAL AREA', o.metalArea.toFixed(2) + ' mm²  (derived)']);
  L.push(['FILL, ROUND WIRES', cur.lay === 'concentric' ? cur.n + '/' + Math.pow(2*cur.layers+1,2) + ' = ' + o.fill.toFixed(3) + '  (derived, exact)' : o.fill.toFixed(2) + '  (assumed; CANDIDATE)']);
  if (o.Dc) L.push(['DIAMETER SAVED', (o.D - o.Dc).toFixed(2) + ' mm, ' + ((1 - o.Dc/o.D)*100).toFixed(1) + '%  by compaction']);
  L.push(['LAY', cur.lay]); L.push(['HATCH', cur.metal === 'Al' ? 'aluminium, 45°' : (cur.metal === 'Cu-Sn' ? 'copper, 135°, tin as a heavy rim' : 'copper, 135°')]);
  if (narrow) g.font = '10px ui-monospace,Consolas,monospace';
  g.strokeStyle = '#12414a'; g.strokeRect(bx - 12, by - 22, bw, L.length*lh + 62);
  L.forEach(([k, v], i) => { g.fillStyle = '#2ee6e6'; g.fillText(k, bx, by + i*lh); g.fillStyle = /CANDIDATE/.test(v) ? '#ffb000' : '#d5dcea'; g.fillText(v, bx, by + i*lh + 12); });
  g.fillStyle = '#8fb3bd'; const words = cur.note.split(' '); let line = '', yy = by + L.length*lh + 6;
  for (const w of words) { if (g.measureText(line + w).width > bw - 24) { g.fillText(line, bx, yy); yy += 14; line = ''; } line += w + ' '; } g.fillText(line, bx, yy);
  const blockBottom = Math.max(yy + 4, by - 22 + L.length*lh + 62);   // the lower of the note and the frame
  g.font = '12px ui-monospace,Consolas,monospace';
  // the drawing checks itself
  const ring = []; if (cur.lay === 'concentric') for (let k = 1; k <= cur.layers; k++) ring.push(6*k);
  // THE PHONE TEST, drawn into the same pass: the title block must not sit over the section, and
  // everything drawn must be inside the clear band between the bar and the footnote.
  const blockTop = by - 22, sectionBottom = cy + R + 70;             // the dimension lines under the circle
  const clearOfSection = narrow ? blockTop - sectionBottom : bx - 12 - (cx + R);
  const insideBand = (cy - R) >= top - 0.5 && blockBottom <= bot + 0.5 && bx - 12 >= 0 && bx - 12 + bw <= W + 0.5;
  window.__selftest = { id:cur.id, viewport:[W, H], narrow, band:[Math.round(top), Math.round(bot)],
    T4_title_block_is_clear_of_the_section: clearOfSection >= 0, clear_px:Math.round(clearOfSection),
    T5_everything_is_inside_the_clear_band: insideBand,
    T6_reserved_rows_match_the_rows_written: rows === L.length, rows_reserved:rows, rows_written:L.length,
    block_bottom_px:Math.round(blockBottom), clear_band_bottom_px:Math.round(bot),
    wires_drawn:o.wires.length, wires_declared:cur.n, T1_count_matches:o.wires.length === cur.n,
    T2_layers_are_6k: cur.lay !== 'concentric' || ring.reduce((a,b)=>a+b,1) === cur.n, layers:ring,
    T3_metal_area_equals_nominal: cur.lay !== 'concentric' || Math.abs(o.metalArea - cur.area) < 1e-9,
    fill:+o.fill.toFixed(4), D_mm:+o.D.toFixed(3), Dc_mm:o.Dc ? +o.Dc.toFixed(3) : null, d_mm:+o.d.toFixed(4) };
  window.__selftest.PASS = window.__selftest.T1_count_matches && window.__selftest.T2_layers_are_6k && window.__selftest.T3_metal_area_equals_nominal
    && window.__selftest.T4_title_block_is_clear_of_the_section && window.__selftest.T5_everything_is_inside_the_clear_band
    && window.__selftest.T6_reserved_rows_match_the_rows_written;
  document.title = 'conductor ' + cur.id + ' selftest ' + (window.__selftest.PASS ? 'PASS' : 'FAIL');
}
addEventListener('resize', draw); draw();
</script>
</body>
</html>

Conductor

A web page in the testcode folder of GlobalGrid2050 that draws on a canvas (units: mm², °C, Ω), covering cables, using IEC 60228 and ISO 128. Published at https://globalgrid2050.com/testcode/wafer-development-environment/202609191345-proof-7/conductor.html.

electricalglobalgrid2050 / testcode/wafer-development-environment/202609191345-proof-7/conductor.html · lines 1–183 of 183 · version 2026-09-19 13:45 · Entry point · pattern hatch (shared by 9 files)

What it does
It draws cables. Defines geometry, hatch, dim, draw. Side effects: changes the web page (DOM).
Why it exists in the grid workflow
Domain stage experimental (path word 'testcode'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow. Domain terms in the code: cables.
Inputs & outputs
Out: web page; canvas drawing.
Downstream impact
It is itself an entry point, published at https://globalgrid2050.com/testcode/wafer-development-environment/202609191345-proof-7/conductor.html.
What it achieves
It is built from the draw step (`draw`). Defines `geometry`, `hatch`, `dim` and 1 more. It responds to resize events.
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
globalgrid2050 · testcode/wafer-development-environment/202609191345-proof-7 · page
Uses
none found
Used by
none found
Produces
geometry, hatch, dim, draw
Defines here
geometry, hatch, dim, draw
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 testcode/wafer-development-environment/202609191345-proof-7/conductor.html:1-183 · blob 7e8738541df5eb97d6919d1a74ed34acab977f9e · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: experimental · users: none · canonical: production_core
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Conductor section</title>
<style>
  :root{--bg:#090c13;--ink:#d5dcea;--dim:#7d8799;--cy:#2ee6e6;--gn:#22ee77;--am:#ffb000;--mg:#ff2bd6}
  *{box-sizing:border-box} html,body{margin:0;height:100%;background:var(--bg);color:var(--ink);
    font:12px/1.55 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;overflow:hidden}
  canvas{position:fixed;inset:0;width:100%;height:100%;touch-action:none}
  #bar{position:fixed;top:0;left:0;right:0;display:flex;gap:8px;align-items:center;padding:8px 12px;z-index:5;
    background:#090c13ee;border-bottom:1px solid #12414a;flex-wrap:wrap}
  #bar b{color:var(--cy);letter-spacing:.16em;text-transform:uppercase;margin-right:10px}
  button{background:#0b1a20;color:#8fb3bd;border:1px solid #12414a;padding:6px 10px;font:inherit;cursor:pointer;text-transform:uppercase;letter-spacing:.06em}
  button.on,button:hover{border-color:var(--cy);color:var(--cy)}
  #foot{position:fixed;left:0;right:0;bottom:0;padding:7px 12px;color:var(--dim);border-top:1px solid #12414a;background:#090c13ee;z-index:5}
  /* THE PHONE. On a narrow screen the title block cannot stand beside the section, so the drawing
     takes the upper part of the clear band and the block is set out beneath it (see draw()). The
     buttons grow to a thumb's size and the footnote collapses rather than taking half the screen. */
  @media (max-width:760px){
    html,body{font-size:11px}
    #bar{padding:6px 8px} #bar b{margin-right:6px}
    button{padding:9px 11px}
    #foot{padding:6px 8px;max-height:22vh;overflow:auto}
  }
</style>
</head>
<body>
<canvas id="c"></canvas>
<div id="bar"><b>Conductor section</b><span id="btns"></span></div>
<div id="foot">a section, not a design &middot; every dimension is derived from the stated inputs or marked CANDIDATE &middot; materials are told apart
  by hatch, as on a drawing, so colour stays free to mean state &middot; no material image is shown because no real, attributed image is held:
  a texture made to look like metal would be a lie &middot; provided as is, without warranty of any kind</div>
<script type="module">
// A CONDUCTOR, DRAWN FROM ARITHMETIC. A concentric stranded conductor is the hexagonal law made of
// metal: one wire, then a layer of 6, then 12, then 18, layer k holding 6k wires on a circle of
// radius k x d. So the wire count of n layers is 3n^2 + 3n + 1 = 1, 7, 19, 37, 61, 91, which is why
// IEC 60228 class 2 strandings are those numbers, and the overall diameter is (2n+1) x d.
// Everything drawn below follows from a nominal area and a wire count. Nothing is traced from a
// photograph and nothing is decorated.
// THE STANDARD'S OWN LIMITS. Each one is a single value read from IEC 60228:2004 (ed. 3.0) against
// the row for that class and that nominal area, and each carries the table it came from. A value
// with a source is KEYED; a value without one stays CANDIDATE and is drawn in amber. No table and
// no column of a table is reproduced here: the standard is licensed, and a column is disclosure.
// The drawing is then checked against these limits by the page itself, at the bottom of draw().
const IEC = 'IEC 60228:2004 (ed. 3.0)';
const CASES = [
  { id:'al400', name:'400 mm² aluminium · class 2 · 61 wires', area:400, n:61, metal:'Al', layers:4, lay:'concentric',
    compactFill:0.90,
    minWires:61, minWiresSrc:IEC + ', Table 2, circular',
    minWiresCompacted:53, minWiresCompactedSrc:IEC + ', Table 2, circular compacted',
    Rmax:0.0778, RmaxSrc:IEC + ', Table 2, aluminium, maximum at 20 °C',
    note:'Circular compacted. Compaction deforms the round wires so the same metal fits a smaller circle, and it also frees the conductor from the circular minimum: the standard asks 61 wires round, 53 compacted.' },
  { id:'cu6c5', name:'6 mm² tinned copper · class 5 · 84 × 0.30', area:6, n:84, d:0.30, metal:'Cu-Sn', lay:'bunched',
    dMax:0.31, dMaxSrc:IEC + ', Table 3, class 5, maximum diameter of wires',
    Rmax:3.39, RmaxSrc:IEC + ', Table 3, metal coated, maximum at 20 °C',
    note:'Flexible, as used in H1Z2Z2-K solar cable, which is TINNED: the metal coated resistance is the one that applies to it, not the plain copper one. Bunched wires have NO fixed positions: this arrangement is an idealisation.' },
  { id:'cu6c6', name:'6 mm² copper · class 6 · 189 × 0.20', area:6, n:189, d:0.20, metal:'Cu', lay:'bunched',
    dMax:0.21, dMaxSrc:IEC + ', Table 4, class 6, maximum diameter of wires',
    Rmax:3.30, RmaxSrc:IEC + ', Table 4, plain, maximum at 20 °C',
    note:'Extra flexible. Finer wire, more of them, same metal. Bunched: an idealisation, as above.' }
];
const cv = document.getElementById('c'), g = cv.getContext('2d'); let cur = CASES[0];
const btns = document.getElementById('btns');
CASES.forEach(c => { const b = document.createElement('button'); b.textContent = c.id; b.onclick = () => { cur = c; draw(); }; c.btn = b; btns.appendChild(b); });

function geometry(c){
  const o = { wires:[] };
  if (c.lay === 'concentric') {
    o.d = Math.sqrt(4*c.area / (c.n*Math.PI));                 // from A = n x pi d^2 / 4
    o.D = (2*c.layers + 1) * o.d;                              // across the layers
    o.wires.push([0,0]);
    for (let k = 1; k <= c.layers; k++) for (let j = 0; j < 6*k; j++) { const a = 2*Math.PI*j/(6*k) + (k%2 ? 0 : Math.PI/(6*k));
      o.wires.push([k*o.d*Math.cos(a), k*o.d*Math.sin(a)]); }
    o.fill = c.n*o.d*o.d / (o.D*o.D);                          // metal area over circle area
    o.Dc = Math.sqrt(4*c.area / (Math.PI*c.compactFill));      // the circle the same metal needs at the compacted fill
    o.metalArea = c.n*Math.PI*o.d*o.d/4;
  } else {
    o.d = c.d; o.metalArea = c.n*Math.PI*o.d*o.d/4; o.fill = 0.75; o.D = o.d*Math.sqrt(c.n/o.fill);
    for (let i = 0; i < c.n; i++) { const r = (o.D/2 - o.d/2)*Math.sqrt((i+0.5)/c.n), a = i*2.399963229728653; o.wires.push([r*Math.cos(a), r*Math.sin(a)]); }
  }
  return o;
}
function hatch(x, y, r, metal){                                  // ISO 128 style: material by hatch, not by colour
  g.save(); g.beginPath(); g.arc(x, y, r, 0, 6.2832); g.clip(); g.strokeStyle = 'rgba(201,211,230,.55)'; g.lineWidth = 1;
  const step = Math.max(3, r/3.2), ang = metal === 'Al' ? Math.PI/4 : -Math.PI/4;
  for (let t = -2*r; t <= 2*r; t += step) { g.beginPath(); g.moveTo(x + t - 2*r*Math.cos(ang), y - 2*r*Math.sin(ang)); g.lineTo(x + t + 2*r*Math.cos(ang), y + 2*r*Math.sin(ang)); g.stroke(); }
  if (metal === 'Cu-Sn') { g.strokeStyle = 'rgba(201,211,230,.9)'; g.lineWidth = Math.max(1, r*0.16); g.beginPath(); g.arc(x, y, r*0.92, 0, 6.2832); g.stroke(); }
  g.restore();
}
function dim(x1, x2, y, label, colour){
  g.strokeStyle = colour; g.fillStyle = colour; g.lineWidth = 1; g.beginPath();
  g.moveTo(x1, y-7); g.lineTo(x1, y+7); g.moveTo(x2, y-7); g.lineTo(x2, y+7); g.moveTo(x1, y); g.lineTo(x2, y); g.stroke();
  g.textAlign = 'center'; g.fillText(label, (x1+x2)/2, y - 8); g.textAlign = 'start';
}
function draw(){
  cv.width = innerWidth; cv.height = innerHeight; CASES.forEach(c => c.btn.className = c === cur ? 'on' : '');
  // THE CLEAR BAND. The bar and the footnote are fixed, so the drawing is fitted to what is left of
  // the window, measured, not guessed. Narrow: the section on top, the title block underneath.
  const barH = document.getElementById('bar').getBoundingClientRect().height;
  const footH = document.getElementById('foot').getBoundingClientRect().height;
  const W = cv.width, H = cv.height, top = barH + 10, bot = H - footH - 10, band = Math.max(60, bot - top);
  const narrow = W < 760;
  const o = geometry(cur);
  // The title block's height is known before a word of it is written: it has a fixed number of
  // rows. On a narrow screen it is reserved first and the section is given what is left, so the
  // block can never be pushed off the bottom of the screen by a larger drawing.
  const rows = 9 + (o.Dc ? 1 : 0) + 2*((cur.dMax ? 1 : 0) + (cur.minWires ? 1 : 0) + (cur.minWiresCompacted ? 1 : 0) + (cur.Rmax ? 1 : 0));
  const lh = narrow ? 22 : 30;
  const blockH = narrow ? rows*lh + 62 + 46 : 0;                    // rows, the frame, three lines of note
  const avail = narrow ? Math.max(120, band - blockH - 12) : band;
  const cx = narrow ? W*0.50 : W*0.40;
  const R = narrow ? Math.min(W*0.40, (avail - 84)/2) : o.D/2 * (Math.min(W*0.62, band*0.86) / (o.D*1.12));
  const S = 2*R/o.D;
  const cy = narrow ? top + 10 + R : top + band*0.52;
  g.fillStyle = '#090c13'; g.fillRect(0,0,W,H); g.font = '12px ui-monospace,Consolas,monospace';
  for (const [x,y] of o.wires) { const px = cx + x*S, py = cy - y*S, r = o.d/2*S;
    hatch(px, py, r, cur.metal); g.strokeStyle = '#c9d3e6'; g.lineWidth = 1.2; g.beginPath(); g.arc(px, py, r, 0, 6.2832); g.stroke(); }
  g.strokeStyle = 'rgba(46,230,230,.55)'; g.setLineDash([6,5]); g.beginPath(); g.arc(cx, cy, R, 0, 6.2832); g.stroke(); g.setLineDash([]);
  dim(cx - R, cx + R, cy + R + 34, 'Ø ' + o.D.toFixed(2) + ' mm  across the ' + (cur.lay === 'concentric' ? 'round wires, (2n+1) × d' : 'bundle, idealised'), '#2ee6e6');
  if (o.Dc) { g.strokeStyle = '#ffb000'; g.lineWidth = 1.6; g.beginPath(); g.arc(cx, cy, o.Dc/2*S, 0, 6.2832); g.stroke();
    dim(cx - o.Dc/2*S, cx + o.Dc/2*S, cy + R + 66, 'Ø ' + o.Dc.toFixed(2) + ' mm  after compaction to fill ' + cur.compactFill.toFixed(2) + '  (CANDIDATE input)', '#ffb000'); }
  const w0 = o.wires[o.wires.length-1]; dim(cx + w0[0]*S - o.d/2*S, cx + w0[0]*S + o.d/2*S, cy - w0[1]*S - o.d/2*S - 12, 'd ' + o.d.toFixed(3) + ' mm', '#ff2bd6');
  // the title block, as on a drawing
  const bx = narrow ? 14 : W*0.70, by = narrow ? Math.round(top + avail + 34) : top + 24;
  const bw = narrow ? W - 28 : W - bx, L = [];
  L.push(['TITLE', cur.name]); L.push(['STANDARD', 'IEC 60228, conductors of insulated cables']);
  L.push(['NOMINAL AREA', cur.area + ' mm²  (input)']); L.push(['WIRES', cur.n + (cur.lay === 'concentric' ? '  = 3n²+3n+1, n = ' + cur.layers + '  (derived)' : '  (input)')]);
  L.push(['WIRE DIAMETER', o.d.toFixed(3) + ' mm  ' + (cur.lay === 'concentric' ? '(derived from area and count)' : '(input; CANDIDATE against the standard)')]);
  L.push(['METAL AREA', o.metalArea.toFixed(2) + ' mm²  (derived)']);
  L.push(['FILL, ROUND WIRES', cur.lay === 'concentric' ? cur.n + '/' + Math.pow(2*cur.layers+1,2) + ' = ' + o.fill.toFixed(3) + '  (derived, exact)' : o.fill.toFixed(2) + '  (assumed; CANDIDATE)']);
  if (o.Dc) L.push(['DIAMETER SAVED', (o.D - o.Dc).toFixed(2) + ' mm, ' + ((1 - o.Dc/o.D)*100).toFixed(1) + '%  by compaction']);
  // WHAT THE STANDARD ASKS, and whether this drawing obeys it. One value, one citation, each time.
  if (cur.dMax) L.push(['MAX WIRE DIAMETER', cur.dMax.toFixed(2) + ' mm  ' + (o.d <= cur.dMax + 1e-12 ? 'drawn ' + o.d.toFixed(2) + ' mm, within' : 'drawn ' + o.d.toFixed(2) + ' mm, OVER')]);
  if (cur.dMaxSrc) L.push(['  its source', cur.dMaxSrc]);
  if (cur.minWires) L.push(['MIN WIRES, CIRCULAR', cur.minWires + '  drawn ' + cur.n + (cur.n >= cur.minWires ? ', at or over' : ', UNDER')]);
  if (cur.minWiresSrc) L.push(['  its source', cur.minWiresSrc]);
  if (cur.minWiresCompacted) L.push(['MIN WIRES, COMPACTED', cur.minWiresCompacted + '  the same metal, freed from the circular minimum']);
  if (cur.minWiresCompactedSrc) L.push(['  its source', cur.minWiresCompactedSrc]);
  if (cur.Rmax) L.push(['MAX RESISTANCE, 20 °C', cur.Rmax + ' Ω/km']);
  if (cur.RmaxSrc) L.push(['  its source', cur.RmaxSrc]);
  L.push(['LAY', cur.lay]); L.push(['HATCH', cur.metal === 'Al' ? 'aluminium, 45°' : (cur.metal === 'Cu-Sn' ? 'copper, 135°, tin as a heavy rim' : 'copper, 135°')]);
  if (narrow) g.font = '10px ui-monospace,Consolas,monospace';
  g.strokeStyle = '#12414a'; g.strokeRect(bx - 12, by - 22, bw, L.length*lh + 62);
  L.forEach(([k, v], i) => { g.fillStyle = '#2ee6e6'; g.fillText(k, bx, by + i*lh); g.fillStyle = /CANDIDATE/.test(v) ? '#ffb000' : '#d5dcea'; g.fillText(v, bx, by + i*lh + 12); });
  g.fillStyle = '#8fb3bd'; const words = cur.note.split(' '); let line = '', yy = by + L.length*lh + 6;
  for (const w of words) { if (g.measureText(line + w).width > bw - 24) { g.fillText(line, bx, yy); yy += 14; line = ''; } line += w + ' '; } g.fillText(line, bx, yy);
  const blockBottom = Math.max(yy + 4, by - 22 + L.length*lh + 62);   // the lower of the note and the frame
  g.font = '12px ui-monospace,Consolas,monospace';
  // the drawing checks itself
  const ring = []; if (cur.lay === 'concentric') for (let k = 1; k <= cur.layers; k++) ring.push(6*k);
  // THE PHONE TEST, drawn into the same pass: the title block must not sit over the section, and
  // everything drawn must be inside the clear band between the bar and the footnote.
  const blockTop = by - 22, sectionBottom = cy + R + 70;             // the dimension lines under the circle
  const clearOfSection = narrow ? blockTop - sectionBottom : bx - 12 - (cx + R);
  const insideBand = (cy - R) >= top - 0.5 && blockBottom <= bot + 0.5 && bx - 12 >= 0 && bx - 12 + bw <= W + 0.5;
  window.__selftest = { id:cur.id, viewport:[W, H], narrow, band:[Math.round(top), Math.round(bot)],
    T4_title_block_is_clear_of_the_section: clearOfSection >= 0, clear_px:Math.round(clearOfSection),
    T5_everything_is_inside_the_clear_band: insideBand,
    T6_reserved_rows_match_the_rows_written: rows === L.length, rows_reserved:rows, rows_written:L.length,
    // THE STANDARD'S LIMITS, checked against what was actually drawn, not against what was intended
    T7_every_wire_is_at_or_under_the_table_maximum: !cur.dMax || o.d <= cur.dMax + 1e-12,
    T8_the_wire_count_is_at_or_over_the_table_minimum: !cur.minWires || cur.n >= cur.minWires,
    wire_diameter_drawn_mm: +o.d.toFixed(4), wire_diameter_maximum_mm: cur.dMax || null,
    wires_drawn_count: cur.n, wires_minimum_circular: cur.minWires || null, wires_minimum_compacted: cur.minWiresCompacted || null,
    maximum_resistance_ohm_per_km_at_20C: cur.Rmax || null, cited_to: cur.dMaxSrc || cur.minWiresSrc || null,
    block_bottom_px:Math.round(blockBottom), clear_band_bottom_px:Math.round(bot),
    wires_drawn:o.wires.length, wires_declared:cur.n, T1_count_matches:o.wires.length === cur.n,
    T2_layers_are_6k: cur.lay !== 'concentric' || ring.reduce((a,b)=>a+b,1) === cur.n, layers:ring,
    T3_metal_area_equals_nominal: cur.lay !== 'concentric' || Math.abs(o.metalArea - cur.area) < 1e-9,
    fill:+o.fill.toFixed(4), D_mm:+o.D.toFixed(3), Dc_mm:o.Dc ? +o.Dc.toFixed(3) : null, d_mm:+o.d.toFixed(4) };
  window.__selftest.PASS = window.__selftest.T1_count_matches && window.__selftest.T2_layers_are_6k && window.__selftest.T3_metal_area_equals_nominal
    && window.__selftest.T4_title_block_is_clear_of_the_section && window.__selftest.T5_everything_is_inside_the_clear_band
    && window.__selftest.T6_reserved_rows_match_the_rows_written
    && window.__selftest.T7_every_wire_is_at_or_under_the_table_maximum
    && window.__selftest.T8_the_wire_count_is_at_or_over_the_table_minimum;
  document.title = 'conductor ' + cur.id + ' selftest ' + (window.__selftest.PASS ? 'PASS' : 'FAIL');
}
addEventListener('resize', draw); draw();
</script>
</body>
</html>