GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Solar and storage design / solar-electrical-topology-analysis-engine-text-based / b9-sandbox

Solar Electrical Topology Analysis Engine Text Based — B9 Sandbox Style Sheet and 2 more files

A style sheet. Served with the page at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/b9-sandbox/.

676 lines of CSS and JavaScript and HTML from solar-electrical-topology-analysis-engine-text-based, in 3 files. Topic: Solar and storage design. Section 201 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. Model transform · solar-electrical-topology-analysis-engine-text-based / b9-sandbox/model.js lines 1–281
  2. Solar Electrical Topology Analysis Engine Text Based — B9 Sandbox Style Sheet render · solar-electrical-topology-analysis-engine-text-based / b9-sandbox/styles.css lines 1–323
  3. Tests test · solar-electrical-topology-analysis-engine-text-based / b9-sandbox/tests.html lines 1–72

Model

A JavaScript module in Solar Electrical Topology Analysis Engine Text Based that builds scene (`buildScene`), derives summary (`deriveSummary`) and converts to geo (`toGeoJson`). Served with the page at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/b9-sandbox/.

transformsolar-electrical-topology-analysis-engine-text-based / b9-sandbox/model.js · lines 1–281 of 281 · pattern topologyOrder (shared by 2 files)

What it does
It calculates its inputs. Defines 7 functions or classes, including makeId, modulePitch, rowSpan, topologyOrder, buildScene.
Why it exists in the grid workflow
Domain stage experimental (path word 'sandbox'): 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 2 files: Solar Electrical Topology Analysis Engine Text Based — B9 Sandbox (solar-electrical-topology-analysis-engine-text-based, https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/b9-sandbox/); Tests (solar-electrical-topology-analysis-engine-text-based, https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/b9-sandbox/). Reached from 2 other entry points, including Solar Electrical Topology Analysis Engine Text Based — B9 Sandbox Page (solar-electrical-topology-analysis-engine-text-based, https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/b9-sandbox/); Tests (solar-electrical-topology-analysis-engine-text-based, https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/b9-sandbox/tests.html).
What it achieves
It makes id (`makeId`), builds scene (`buildScene`) and derives summary (`deriveSummary`). Defines `makeId`, `modulePitch`, `rowSpan` and 4 more.
Why it matters
Imported by Solar Electrical Topology Analysis Engine Text Based — B9 Sandbox. Checked by Tests.
Application
solar-electrical-topology-analysis-engine-text-based · b9-sandbox · JavaScript module
Uses
none found
Used by
imported by Solar Electrical Topology Analysis Engine Text Based — B9 Sandbox (import), imported by Tests (import)
Produces
SCHEMA_VERSION, makeId, modulePitch, rowSpan, topologyOrder, buildScene, deriveSummary, toGeoJson
Defines here
makeId, modulePitch, rowSpan, topologyOrder, buildScene, deriveSummary, toGeoJson
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
solar-electrical-topology-analysis-engine-text-based@d3b4c497144c2c9b3e8f0e82117e7e9abe4672b9 b9-sandbox/model.js:1-281 · blob 0b029482c05b896fa63cd5936c373beb98062dfe · GitHub at these lines
State
achieves: name · context: readme_derived · stage: transform · effects: none found · domain stage: experimental · users: none · canonical: production_core
export const SCHEMA_VERSION = "b9-scene-0.1.0";

export function makeId(prefix, index) {
  return `${prefix}-${String(index).padStart(4, "0")}`;
}

export function modulePitch(scene) {
  const alongRow = scene.module.orientation === "portrait"
    ? scene.module.widthM
    : scene.module.heightM;
  return alongRow + scene.module.gapM;
}

export function rowSpan(scene) {
  const count = scene.electrical.modulesPerString;
  const alongRow = scene.module.orientation === "portrait"
    ? scene.module.widthM
    : scene.module.heightM;
  return count * alongRow + Math.max(0, count - 1) * scene.module.gapM;
}

export function topologyOrder(moduleCount, topology, customText = "") {
  if (topology === "sequential") {
    return Array.from({ length: moduleCount }, (_, index) => index + 1);
  }

  if (topology === "leapfrog") {
    const odd = [];
    const even = [];
    for (let number = 1; number <= moduleCount; number += 1) {
      if (number % 2 === 1) {
        odd.push(number);
      } else {
        even.push(number);
      }
    }
    return odd.concat(even.reverse());
  }

  if (topology === "mirrored-sequential") {
    return Array.from({ length: moduleCount }, (_, index) => moduleCount - index);
  }

  if (topology === "alternating-return") {
    const first = [];
    const second = [];
    for (let number = 1; number <= moduleCount; number += 1) {
      if (number <= Math.ceil(moduleCount / 2)) {
        first.push(number);
      } else {
        second.unshift(number);
      }
    }
    return first.concat(second);
  }

  const custom = customText
    .split(/[^0-9]+/)
    .map((value) => Number(value))
    .filter((value) => Number.isInteger(value));

  if (custom.length !== moduleCount) {
    return [];
  }

  const unique = new Set(custom);
  if (unique.size !== moduleCount) {
    return [];
  }

  const valid = custom.every((value) => value >= 1 && value <= moduleCount);
  return valid ? custom : [];
}

export function buildScene(input, cartridge) {
  const scene = {
    schemaVersion: SCHEMA_VERSION,
    cartridge: {
      id: cartridge.id,
      name: cartridge.name,
      version: cartridge.version,
      faces: cartridge.faces,
      modulesHigh: cartridge.modulesHigh,
      tracker: cartridge.tracker,
      eastWest: cartridge.eastWest,
    },
    module: {
      widthM: input.moduleWidthM,
      heightM: input.moduleHeightM,
      gapM: input.moduleGapM,
      orientation: input.orientation,
      positiveLeadM: input.positiveLeadM,
      negativeLeadM: input.negativeLeadM,
      junctionBoxMode: input.junctionBoxMode,
    },
    geometry: {
      lowEdgeM: input.lowEdgeM,
      highEdgeM: input.highEdgeM,
      ridgeGapM: input.ridgeGapM,
      rowPitchM: input.rowPitchM,
      trackerAngleDeg: input.trackerAngleDeg,
      inverterDistanceM: input.inverterDistanceM,
    },
    electrical: {
      modulesPerString: input.modulesPerString,
      stringCount: input.stringCount,
      topology: input.topology,
      customOrder: input.customOrder,
      externalCableCsaMm2: input.externalCableCsaMm2,
      factoryLeadCsaMm2: input.factoryLeadCsaMm2,
    },
    modules: [],
    strings: [],
    warnings: [],
  };

  const pitch = modulePitch(scene);
  const order = topologyOrder(
    scene.electrical.modulesPerString,
    scene.electrical.topology,
    scene.electrical.customOrder,
  );

  if (order.length === 0) {
    scene.warnings.push("Custom electrical order is invalid or incomplete.");
  }

  const modulesPerString = scene.electrical.modulesPerString;
  const stringCount = scene.electrical.stringCount;

  for (let stringIndex = 0; stringIndex < stringCount; stringIndex += 1) {
    const stringId = makeId("S", stringIndex + 1);
    const stringModules = [];

    for (let moduleIndex = 0; moduleIndex < modulesPerString; moduleIndex += 1) {
      const moduleNumber = moduleIndex + 1;
      const moduleId = `${stringId}-M${moduleNumber}`;
      const x = moduleIndex * pitch;
      const y = stringIndex * scene.geometry.rowPitchM;
      const moduleRecord = {
        id: moduleId,
        stringId,
        moduleNumber,
        xM: x,
        yM: y,
        widthM: scene.module.orientation === "portrait"
          ? scene.module.widthM
          : scene.module.heightM,
        heightM: scene.module.orientation === "portrait"
          ? scene.module.heightM
          : scene.module.widthM,
        negativeTerminalId: `${moduleId}-NEG`,
        positiveTerminalId: `${moduleId}-POS`,
      };
      scene.modules.push(moduleRecord);
      stringModules.push(moduleRecord);
    }

    const connections = [];
    for (let index = 0; index < order.length - 1; index += 1) {
      const fromNumber = order[index];
      const toNumber = order[index + 1];
      connections.push({
        id: `${stringId}-C${String(index + 1).padStart(2, "0")}`,
        fromTerminalId: `${stringId}-M${fromNumber}-POS`,
        toTerminalId: `${stringId}-M${toNumber}-NEG`,
        fromModule: fromNumber,
        toModule: toNumber,
      });
    }

    scene.strings.push({
      id: stringId,
      moduleIds: stringModules.map((module) => module.id),
      order,
      connections,
      freeNegativeTerminalId: order.length
        ? `${stringId}-M${order[0]}-NEG`
        : null,
      freePositiveTerminalId: order.length
        ? `${stringId}-M${order[order.length - 1]}-POS`
        : null,
    });
  }

  const requiredReachM = scene.electrical.topology === "leapfrog"
    ? 2 * pitch
    : pitch;
  const availableReachM = scene.module.positiveLeadM
    + scene.module.negativeLeadM;

  scene.feasibility = {
    requiredReachM,
    availableReachM,
    passes: availableReachM + 1e-9 >= requiredReachM,
    shortfallM: Math.max(0, requiredReachM - availableReachM),
  };

  if (!scene.feasibility.passes) {
    scene.warnings.push(
      `Factory leads are short by ${scene.feasibility.shortfallM.toFixed(3)} m.`,
    );
  }

  return scene;
}

export function deriveSummary(scene) {
  const spanM = rowSpan(scene);
  const strings = scene.electrical.stringCount;
  const sequentialExtraM = scene.electrical.topology === "sequential"
    ? spanM * strings
    : 0;
  const baseHomeRunM = 2 * scene.geometry.inverterDistanceM * strings;
  const externalCableM = baseHomeRunM + sequentialExtraM;
  const factoryLeadM = scene.electrical.modulesPerString
    * strings
    * (scene.module.positiveLeadM + scene.module.negativeLeadM);
  const connectorCount = scene.strings.reduce(
    (total, stringRecord) => total + stringRecord.connections.length + 2,
    0,
  );
  const commercialExternalCopperKg =
    scene.electrical.externalCableCsaMm2 * (externalCableM / 1000) * 9.6;
  const commercialFactoryCopperKg =
    scene.electrical.factoryLeadCsaMm2 * (factoryLeadM / 1000) * 9.6;

  return {
    moduleCount: scene.modules.length,
    stringCount: strings,
    rowSpanM: spanM,
    connectionCount: connectorCount,
    externalCableM,
    factoryLeadM,
    commercialExternalCopperKg,
    commercialFactoryCopperKg,
    totalCommercialCopperKg:
      commercialExternalCopperKg + commercialFactoryCopperKg,
    freeNegative: scene.strings[0]?.freeNegativeTerminalId ?? "—",
    freePositive: scene.strings[0]?.freePositiveTerminalId ?? "—",
  };
}

export function toGeoJson(scene) {
  const features = scene.modules.map((module) => {
    const x0 = module.xM;
    const y0 = module.yM;
    const x1 = x0 + module.widthM;
    const y1 = y0 + module.heightM;
    return {
      type: "Feature",
      id: module.id,
      properties: {
        schema_version: scene.schemaVersion,
        object_type: "module",
        string_id: module.stringId,
        module_number: module.moduleNumber,
      },
      geometry: {
        type: "Polygon",
        coordinates: [[
          [x0, y0],
          [x1, y0],
          [x1, y1],
          [x0, y1],
          [x0, y0],
        ]],
      },
    };
  });

  return {
    type: "FeatureCollection",
    name: "b9-array-scene",
    crs: {
      type: "name",
      properties: { name: "LOCAL_ENGINEERING_METRES" },
    },
    features,
  };
}

Solar Electrical Topology Analysis Engine Text Based — B9 Sandbox Style Sheet

A style sheet. Served with the page at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/b9-sandbox/.

rendersolar-electrical-topology-analysis-engine-text-based / b9-sandbox/styles.css · lines 1–323 of 323 · Entry point

What it does
Side effects: changes the web page (DOM).
Why it exists in the grid workflow
Domain stage experimental (path word 'sandbox'): 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: Solar Electrical Topology Analysis Engine Text Based — B9 Sandbox Page (solar-electrical-topology-analysis-engine-text-based, https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/b9-sandbox/). Reached from 1 other entry point, including Tests (solar-electrical-topology-analysis-engine-text-based, https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/b9-sandbox/tests.html). It is itself an entry point, published at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/b9-sandbox/.
What it achieves
No statement of purpose was found in the file, a README line naming it, or its name.
Why it matters
Loaded by the B9 Sandbox page at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/b9-sandbox/.
Application
solar-electrical-topology-analysis-engine-text-based · b9-sandbox · style sheet
Uses
none found
Used by
loaded by Solar Electrical Topology Analysis Engine Text Based — B9 Sandbox 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
solar-electrical-topology-analysis-engine-text-based@d3b4c497144c2c9b3e8f0e82117e7e9abe4672b9 b9-sandbox/styles.css:1-323 · blob 7fabcd1df307da8c68a7eeb9e3180aa174a2a946 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: experimental · users: none · canonical: production_core
:root {
  color-scheme: dark;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  --bg: #071018;
  --panel: #0d1721;
  --panel-2: #111f2d;
  --line: #2a4052;
  --text: #edf7ff;
  --muted: #9fb2c2;
  --cyan: #36d7ff;
  --green: #62e39a;
  --amber: #ffbe63;
  --red: #ff6b7a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #08121b, #03070b 60%);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 340px;
  min-height: 100vh;
}

.sidebar,
.inspector {
  background: rgba(8, 17, 25, 0.96);
  border-right: 1px solid var(--line);
  padding: 18px;
  overflow: auto;
}

.inspector {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.brand {
  margin-bottom: 18px;
}

.brand small {
  display: block;
  color: var(--cyan);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.brand h1 {
  margin: 8px 0 6px;
  font-size: 1.45rem;
}

.brand p,
.help,
.status-note {
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.88rem;
}

.panel {
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 0.9rem;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.field {
  display: grid;
  grid-template-columns: 1fr 118px;
  gap: 10px;
  align-items: center;
  margin: 8px 0;
}

.field label {
  font-size: 0.84rem;
  color: #d8e5ef;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid #385064;
  border-radius: 6px;
  background: #071018;
  color: var(--text);
  padding: 7px 8px;
}

.field textarea {
  min-height: 72px;
  resize: vertical;
}

.field.full {
  grid-template-columns: 1fr;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #09131c;
}

.toolbar button,
.actions button {
  border: 1px solid #3c566a;
  border-radius: 7px;
  background: #102131;
  color: var(--text);
  padding: 9px 12px;
}

.toolbar button.active {
  border-color: var(--cyan);
  background: #0e4b60;
  color: #ecfbff;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.actions button.primary {
  border-color: var(--cyan);
  background: #0d5269;
}

.stage-wrap {
  position: relative;
  flex: 1;
  min-height: 640px;
  overflow: hidden;
  background:
    linear-gradient(rgba(65, 101, 127, 0.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(65, 101, 127, 0.14) 1px, transparent 1px),
    #02070b;
  background-size: 24px 24px;
}

#stage {
  width: 100%;
  height: 100%;
  min-height: 640px;
  touch-action: none;
  user-select: none;
}

.legend {
  position: absolute;
  left: 14px;
  bottom: 14px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(3, 9, 14, 0.88);
  color: var(--muted);
  font-size: 0.78rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin: 0;
}

.summary-grid dt {
  color: var(--muted);
  font-size: 0.78rem;
}

.summary-grid dd {
  margin: 0;
  text-align: right;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
}

.warning-list {
  margin: 0;
  padding-left: 18px;
  color: #ffd2d6;
  font-size: 0.84rem;
  line-height: 1.45;
}

.pass {
  color: var(--green);
}

.fail {
  color: var(--red);
}

.module-rect {
  fill: #123d53;
  stroke: #49d9ff;
  stroke-width: 1.5;
}

.module-label {
  fill: #eaf9ff;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.terminal-neg {
  fill: #59b6ff;
}

.terminal-pos {
  fill: #ff6474;
}

.connection {
  fill: none;
  stroke: #f1f5f8;
  stroke-width: 2;
}

.connection.turnaround {
  stroke: var(--amber);
  stroke-width: 3;
}

.inverter {
  fill: #ffb54c;
  stroke: #ffe0a8;
  stroke-width: 2;
}

.dimension,
.ground-line,
.structure-line {
  fill: none;
  stroke: #7d93a6;
  stroke-width: 1.5;
}

.structure-line {
  stroke: #b3c1cb;
  stroke-width: 3;
}

.view-title {
  fill: #ffffff;
  font-size: 18px;
  font-weight: 800;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 290px minmax(0, 1fr);
  }

  .inspector {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar,
  .inspector {
    border: 0;
    border-bottom: 1px solid var(--line);
  }

  .stage-wrap,
  #stage {
    min-height: 520px;
  }
}

Tests

A web page in Solar Electrical Topology Analysis Engine Text Based. Published at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/b9-sandbox/tests.html.

testsolar-electrical-topology-analysis-engine-text-based / b9-sandbox/tests.html · lines 1–72 of 72 · Entry point

What it does
It tests its inputs. Side effects: changes the web page (DOM).
Why it exists in the grid workflow
Domain stage experimental (path word 'sandbox'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
Inputs & outputs
Out: web page.
Downstream impact
It is itself an entry point, published at https://ventusltd.github.io/solar-electrical-topology-analysis-engine-text-based/b9-sandbox/tests.html.
What it achieves
No statement of purpose was found in the file, a README line naming it, or its name.
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
solar-electrical-topology-analysis-engine-text-based · b9-sandbox · page
Uses
Solar Electrical Topology Analysis Engine Text Based — B9 Sandbox Page (link), Tests (script src)
Used by
none found
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
solar-electrical-topology-analysis-engine-text-based@d3b4c497144c2c9b3e8f0e82117e7e9abe4672b9 b9-sandbox/tests.html:1-72 · blob 2d092b6cb094c15625d23ee9c9502b63214c61bf · 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>B9 Sandbox Tests</title>
  <style>
    :root {
      color-scheme: dark;
      font-family: system-ui, sans-serif;
    }

    body {
      margin: 0;
      padding: 28px;
      background: #071018;
      color: #edf7ff;
    }

    main {
      max-width: 1100px;
      margin: 0 auto;
    }

    table {
      width: 100%;
      border-collapse: collapse;
      margin-top: 20px;
      background: #0d1721;
    }

    th,
    td {
      padding: 10px 12px;
      border: 1px solid #2a4052;
      text-align: left;
    }

    .pass {
      color: #62e39a;
      font-weight: 800;
    }

    .fail {
      color: #ff6b7a;
      font-weight: 800;
    }

    a {
      color: #36d7ff;
    }
  </style>
</head>
<body>
  <main>
    <p><a href="./">← Back to B9 sandbox</a></p>
    <h1>B9 hand-calculated browser fixtures</h1>
    <p id="overall">Running…</p>
    <table>
      <thead>
        <tr>
          <th>Status</th>
          <th>Invariant / canary</th>
          <th>Observed result</th>
        </tr>
      </thead>
      <tbody id="results"></tbody>
    </table>
  </main>
  <script type="module" src="./tests.js"></script>
</body>
</html>