In this section
- Inverter 48 electrical · globalgrid2050 / ventus/wiring/inverter-48.mjs lines 1–165
- Inverter Station electrical · globalgrid2050 / ventus/wiring/inverter-station.mjs lines 1–84
- Cpu Ref ingest · gpu-drivers-for-global-grid / cuda-maths/solar-billion/cpu_ref.py lines 1–116
- Cpu Vec transform · gpu-drivers-for-global-grid / cuda-maths/solar-billion/cpu_vec.py lines 1–137
- GPU Vec transform · gpu-drivers-for-global-grid / cuda-maths/solar-billion/gpu_vec.py lines 1–57
- Cuda Maths — Solar Billion other · gpu-drivers-for-global-grid / cuda-maths/solar-billion/main.py lines 1–6
- Orient16 Responsive Panel render · gridatlas / atlas/modules/202612031346-orient16-responsive-panel.js lines 1–90
Inverter 48
A JavaScript module in the wiring folder of GlobalGrid2050 that shows hud (`showHud`), applies lengths (`applyLengths`), draws flow overlay (`drawFlowOverlay`) and calculates planar distances. Served with the page at https://globalgrid2050.com/ventus/wiring/.
electricalglobalgrid2050 / ventus/wiring/inverter-48.mjs · lines 1–165 of 165 · Entry point · pattern nativeDrawing (shared by 2 files)
- What it does
- It draws inverter cable lengths, inverter geometry and cables. Defines 24 functions or classes, including $, win, map, polygon, nativeDrawing. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage sub33kv_design (path word 'inverter'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary. Domain terms in the code: cables.
- Inputs & outputs
- In: CSV file inverter-48-cable-lengths.csv; JSON file inverter-48-geometry.json. Out: canvas drawing; SVG drawing.
- Downstream impact
- Used directly by 1 file: GlobalGrid2050 Inverter Flow Check Workflow (globalgrid2050). It is itself an entry point, published at https://globalgrid2050.com/ventus/wiring/.
- What it achieves
- It shows hud (`showHud`), applies lengths (`applyLengths`) and draws flow overlay (`drawFlowOverlay`). Defines `win`, `map`, `polygon` and 19 more. Its code works with 352 kVA. It responds to pointerdown and pointerup events.
- Why it matters
- Run by GlobalGrid2050 Inverter Flow Check Workflow.
- Application
- globalgrid2050 · ventus/wiring · JavaScript module
- Uses
- Inverter 48 Model (import), Inverter 48 Native (import), Inverter 48 Electrical UI (import)
- Used by
- run by GlobalGrid2050 Inverter Flow Check Workflow (workflow run)
- Produces
- $, win, map, polygon, nativeDrawing, add, label, fit, paint, path, summary, save
- Defines here
- $, win, map, polygon, nativeDrawing, add, label, fit, paint, path, summary, save, csv, svg, esc, p, showHud, supplied, applyLengths, lengthsChanged, render, activeWalks, drawFlowOverlay, tick
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 ventus/wiring/inverter-48.mjs:1-165 · blob 4c5b0b8b1acd36288745fed23804265afb3a68ac · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
import {build,sources,length} from './inverter-48-model.mjs';
import {createNativeAdapter} from './inverter-48-native.mjs';
import {mountElectrical} from './inverter-48-electrical-ui.mjs';
const $=id=>document.getElementById(id), frame=$('engine');
let model=build(),ready=false,playing=true,selected='S01',clock=0,last=performance.now(),drawing;
let flowCanvas=null,flowFrames=0,flowScope='all',flowStats={strings:0,homePaths:0};
let nativeAdapter=null,nativeWalks=[],electrical=null,electricalReport=null,tolerance=3;
const enteredLengths=new Map();
const win=()=>frame.contentWindow;
const map=p=>[p[0]*.01,-p[1]*.01];
const polygon=(x,y,w,h)=>[[x,y],[x+w,y],[x+w,y+h],[x,y+h],[x,y]];
function nativeDrawing(){
applyLengths();
const shapes=[],marks=[],b=model.inverterDrawing;
const add=(role,node,pts,extra={})=>{const s={role,node,pts:pts.map(map),order:0,pot:0,...extra};shapes.push(s);return s;};
const label=(text,x,y,size=11,colour='#b6c9dc',extra={})=>marks.push({text,x:x*.01,y:-y*.01,size,colour,minPx:0,rank:0,...extra});
add('inverter','INV-01',polygon(b.x,b.y,b.width,b.height),{fill:'#111b26'});
label('352 kVA inverter',b.x+1,b.y+1,16);label('12 MPPT / 24 STRINGS',b.x+1,b.y+2.5,10);
for(const m of model.modules){add('module',m.id,m.drawing,{fill:'#0c1119',stringId:m.stringId});label(m.id,m.drawing[0][0]+.15,m.drawing[0][1]+.35,9,'#788d9e',{minPx:24});}
for(const l of model.links){
const halves=[win().polySlice(l.drawing,0,.5),win().polySlice(l.drawing,.5,1)];
for(let k=0;k<2;k++)add('cable',l.id+'-'+k,halves[k],{plus:k===0,stringId:l.stringId,weight:1.8,hit:true,says:l.id+' · '+l.routeM.toFixed(2)+' m physical intermodule route',connected:l.connected});
add('mate',l.id+'-mate',[[ (l.drawing[0][0]+l.drawing.at(-1)[0])/2,l.drawing[1][1] ]],{along:[1,0],mated:true});
}
for(const h of model.homes)add('cable','home-'+h.id,h.drawing,{plus:h.sign==='+',stringId:h.stringId,weight:2.5,hit:true,says:h.id+' → '+h.portId+' · '+h.routeM.toFixed(2)+' m estimated physical route',connected:true});
for(const p of model.ports){
add('plug',p.id,[p.drawing],{male:p.sign==='+',plus:p.sign==='+',along:[1,0],pot:p.sign==='+'?1:0});
label(p.stringId+' '+p.sign,p.drawing[0]-6.6,p.drawing[1],10,p.sign==='+'?'#ff9385':'#bed5e8');
}
for(const mppt of model.mppts){const p=model.ports.find(p=>p.mppt===mppt.id);label('MPPT '+String(mppt.id).padStart(2,'0'),b.x+1,p.drawing[1]+1.45,10,'#81dbe2');}
for(const s of model.strings){
const lengths=model.homes.filter(h=>h.stringId===s.id),lengthLabel=['+','-'].map(sign=>{const h=lengths.find(h=>h.sign===sign);return h?sign+' '+h.suppliedLengthM.toFixed(1)+'m'+(enteredLengths.has(h.id)?' E':''):'';}).join(' / ');
label(s.id+(s.connected?' MPPT '+String(s.mppt).padStart(2,'0')+'-'+s.input+' | '+lengthLabel:' / TO OTHER INVERTER — OFF DRAWING'),s.column===1?0:(s.column-1)*30*(model.width+model.gap),s.drawY-.65,10,s.connected?'#9fd4dc':'#eabc74');
for(const [sign,p] of [['-',s.minus],['+',s.plus]]){
add('terminal',s.id+sign,[p],{dot:.0015,pot:sign==='+'?1:0});
if(!s.connected){add('cable',s.id+'-offsheet'+sign,[p,[p[0],p[1]+1.9]],{plus:sign==='+',weight:2});label('↓ '+sign,p[0]-.2,p[1]+(sign==='+'?2.85:2.35),9,'#eabc74');}
}
}
label('EAST FACE / 15 STRINGS / FIVE PORTRAIT ROWS',0,-3.3,14,'#9cdce8');
label('WEST FACE / 15 STRINGS / FIVE PORTRAIT ROWS',0,model.layout.westY-3.3,14,'#9cdce8');
label('30 × 660 Wp = 19.8 kWp / STRING | LENGTHS: ROUTE + '+tolerance+'% ALLOWANCE; E = ENTERED',0,-5.3,11);
label('48 SEPARATE DC CABLES',-29,-5.3,10);
label(model.drawingOffset+' m DRAWING SEPARATION',-29,(b.height+1),10,'#8193a8');
label('NOT TO SCALE',model.arrayWidth-32,(b.height+1),19,'#b9b6ab');
label('OVERSIZED CONDUCTORS / ILLUSTRATIVE ELECTRON FLOW',0,(b.height+1),10,'#8193a8');
add('cable','AC-export',[[b.x,b.height-6],[b.x-8,b.height-6]],{plus:false,weight:3});
label('AC EXPORT → 352 kVA AT 30°C',b.x-5,b.height-2,10);
const g={c:{sheet:0,view:'macro'},N:900,pitch:model.width+.02,pair:0,short:[],links:[],rows:10,cols:90,rowY:[],order:[],bothNear:true,ret:0,row:model.arrayWidth,lead_m:0,field_m:0,ohm:0};
drawing={kind:'string',opened:true,shapes,marks,words:[],conns:[],terminals:[],wiring:true,crossings:[],perM:.01,open:true,g,
freeCamera:true,firstModuleX:0,volts:0,volts_open:0,earth_node:'earth',bounds:{x0:-.6,y0:-.75,x1:1.25,y1:.09},near:{x:0,y:0},mPerUnit:100,amps:0,front:-1,head:-1,walk:null,t0:0,inverter48:true};
g.__draw=drawing;
nativeWalks=nativeAdapter?.build(model)||[];
return {numbers:{modules:900,strings:30,connected:24,ports:48,mppts:12},said:'Thirty east-west strings, 24 connected here, six to another inverter off drawing, 48 separate conductors; NOT TO SCALE.',how:'Source dimensions; generic physical route estimates; illustrative electron animation.',block:g};
}
function fit(bounds){
if(!ready)return;
const w=win(),points=bounds||drawing.shapes.filter(s=>['module','inverter','cable'].includes(s.role)).flatMap(s=>s.pts),xs=points.map(p=>p[0]),ys=points.map(p=>p[1]);
const x0=Math.min(...xs)-.04,x1=Math.max(...xs)+.04,y0=Math.min(...ys)-.07,y1=Math.max(...ys)+.08;
const R=w.eval('Math.sqrt(SPACE)*BODY_RADIUS_MAX'),z=Math.min((w.innerWidth-60)/((x1-x0)*R),(w.innerHeight-60)/((y1-y0)*R));
w.eval('atHome=false;if(body&&body.sld)bodyJump(0);bodyAnim=null;tween=null;cx='+((x0+x1)/2*R)+';cy='+((y0+y1)/2*R)+';zoom='+z+';dirty=true;');
}
function paint(){
if(!ready||!drawing)return;
const w=win(),canvas=w.document.getElementById('sldshapes');if(!canvas)return;
if(w.eval('!!bodyAnim')){w.eval('bodyAnim=null');w.drawSldShapes();}
const ctx=canvas.getContext('2d'),dpr=Math.max(1,Math.min(3,w.devicePixelRatio||1));ctx.save();ctx.setTransform(dpr,0,0,dpr,0,0);
const path=pts=>{ctx.beginPath();pts.map(w.shapePoint).forEach((p,i)=>i?ctx.lineTo(...p):ctx.moveTo(...p));};
// Every home cable is always visible. Selection emphasizes, never hides others.
for(const h of model.homes){const pts=h.drawing.map(map);path(pts);ctx.lineWidth=selected===h.stringId?5:3;ctx.strokeStyle='#05080d';ctx.stroke();path(pts);ctx.lineWidth=selected===h.stringId?2.8:1.7;ctx.strokeStyle=h.sign==='+'?'#ff6255':'#b9cbdf';ctx.stroke();}
for(const walk of nativeWalks){const r=electricalReport?.strings.find(s=>s.id===walk.stringId);walk.operatingCurrentA=r?.currentA??null;walk.invalidOperatingPoint=r?.invalidOperatingPoint??false;}
nativeAdapter?.drawConnectors(ctx,model);
for(const h of model.homes.filter(h=>h.shortM>0)){path(h.drawing.map(map));ctx.strokeStyle='#ffb066';ctx.lineWidth=2;ctx.setLineDash([5,4]);ctx.stroke();ctx.setLineDash([]);}
// Pencil-like architectural annotation remains readable regardless of zoom.
ctx.font='18px "Courier New", monospace';ctx.textAlign='right';ctx.lineWidth=.55;ctx.strokeStyle='#b9b6ab';ctx.strokeText('NOT TO SCALE',w.innerWidth-24,48);
ctx.restore();
}
function summary(){
$('dimensions').textContent='Each physical face: '+model.arrayWidth.toFixed(3)+' m × '+model.faceDepth.toFixed(3)+' m on the slope; 20 mm module gaps; opposed '+model.tilt+'° faces. Drawing rows are spread apart for legibility.';
$('lengths').textContent='48 home-cable route estimates: '+model.totals.homeRouteM.toFixed(1)+' m total. Per-cable values are in the CSV; changing drawing separation does not change these lengths.';
}
function save(name,type,body){const u=URL.createObjectURL(new Blob([body],{type})),a=document.createElement('a');a.href=u;a.download=name;a.click();setTimeout(()=>URL.revokeObjectURL(u),2000);}
function csv(){return 'string,orientation,MPPT,input,polarity,inverter_connector,estimated_physical_route_m,supplied_length_m,allowance_m,shortfall_m\n'+model.homes.map(h=>[h.stringId,model.strings.find(s=>s.id===h.stringId).side,h.mppt,h.input,h.sign,h.portId,h.routeM.toFixed(3),h.suppliedLengthM.toFixed(3),h.allowanceM.toFixed(3),h.shortM.toFixed(3)].join(',')).join('\n');}
function svg(){
const esc=s=>String(s).replaceAll('&','&').replaceAll('<','<').replaceAll('"','"');
const b=model.inverterDrawing,x0=b.x-10,y0=-9,scale=25,W=(model.arrayWidth-x0+5)*scale,H=(b.height+18)*scale;
const p=q=>[(q[0]-x0)*scale,(q[1]-y0)*scale],poly=pts=>pts.map(q=>p(q).join(',')).join(' ');
let text='<svg xmlns="http://www.w3.org/2000/svg" width="'+Math.ceil(W)+'" height="'+H+'" viewBox="0 0 '+W+' '+H+'"><rect width="100%" height="100%" fill="#090c13"/><g fill="none" stroke-linejoin="round">';
for(const m of model.modules)text+='<polyline points="'+poly(m.drawing)+'" stroke="#506477" stroke-width=".8"/>';
text+='<polyline points="'+poly(polygon(b.x,b.y,b.width,b.height))+'" fill="#111b26" stroke="#b5cedd"/>';
for(const l of model.links)for(let k=0;k<2;k++)text+='<polyline points="'+poly(win().polySlice(l.drawing,k/2,(k+1)/2))+'" stroke="'+(k===0?'#ff6255':'#bed5e8')+'" stroke-width="1.6"/>';
for(const s of model.strings.filter(s=>!s.connected))for(const [sign,q]of [['-',s.minus],['+',s.plus]])text+='<polyline points="'+poly([q,[q[0],q[1]+1.9]])+'" stroke="'+(sign==='+'?'#ff6255':'#bed5e8')+'" stroke-width="2.7"/>';
text+='<polyline points="'+poly([[b.x,b.height-6],[b.x-8,b.height-6]])+'" stroke="#c0d1df" stroke-width="3"/>';
for(const h of model.homes)text+='<polyline data-cable="'+h.id+'" points="'+poly(h.drawing)+'" stroke="#05080d" stroke-width="6"/><polyline points="'+poly(h.drawing)+'" stroke="'+(h.sign==='+'?'#ff6255':'#bed5e8')+'" stroke-width="2.7"/>';
text+=nativeAdapter?.svgConnectors(model,p)||'';
text+='</g><g font-family="monospace" fill="#c0d1df">';
for(const m of drawing.marks){if(m.minPx>0)continue;const q=p([m.x*100,-m.y*100]);text+='<text x="'+q[0]+'" y="'+q[1]+'" font-size="'+Math.max(16,m.size*1.4)+'" fill="'+m.colour+'">'+esc(m.text)+'</text>';}
text+='<text x="35" y="35" font-size="24" fill="none" stroke="#b9b6ab" stroke-width=".65">NOT TO SCALE</text><text x="35" y="'+(H-28)+'" font-size="18">475.2 kWp connected DC / 594 kWp installed / 48 home cables / 12 MPPTs / six strings to other inverter, off drawing. Static export.</text></g></svg>';
return text;
}
for(const s of model.strings)$('string').add(new Option(s.id+' · '+s.side+(s.connected?' · MPPT '+s.mppt:' · OTHER INVERTER'),s.id));
for(const s of model.strings.filter(s=>s.connected))$('length-string').add(new Option(s.id+' · '+s.side+' · MPPT '+s.mppt,s.id));
$('menu').onclick=()=>{const panel=document.querySelector('.toolbar');panel.hidden=!panel.hidden;$('menu').setAttribute('aria-expanded',String(!panel.hidden));};
function showHud(show){$('analysis-hud').hidden=!show;$('hud-toggle').setAttribute('aria-expanded',String(show));}
$('hud-toggle').onclick=()=>showHud($('analysis-hud').hidden);$('hud-close').onclick=()=>showHud(false);
$('basis').onclick=()=>{document.querySelector('.bottom').hidden=!document.querySelector('.bottom').hidden;};$('basis-close').onclick=()=>{document.querySelector('.bottom').hidden=true;};
function supplied(h){return enteredLengths.get(h.id)??h.routeM*(1+tolerance/100);}
function applyLengths(){for(const h of model.homes){h.originalDrawing??=structuredClone(h.drawing);h.drawing=structuredClone(h.originalDrawing);h.suppliedLengthM=supplied(h);h.allowanceM=Math.max(0,h.suppliedLengthM-h.routeM);h.shortM=Math.max(0,h.routeM-h.suppliedLengthM);
// A small unfolded allowance loop is schematic; it is never used for physical length.
if(h.allowanceM>0){const lane=h.drawing[1][1],right=h.drawing[1][0],left=h.drawing[2][0],w=Math.min((right-left)*.2,.25+h.allowanceM*.08),x=right-.3,depth=Math.min(.22,.06+h.allowanceM*.005);h.drawing.splice(2,0,[x,lane],[x,lane+depth],[x-w,lane+depth],[x-w,lane]);}
}}
function lengthControls(){const id=$('length-string').value,hs=model.homes.filter(h=>h.stringId===id);for(const sign of ['+','-']){const h=hs.find(h=>h.sign===sign);$('length-'+(sign==='+'?'plus':'minus')).value=supplied(h).toFixed(3);} $('length-readout').textContent=hs.map(h=>h.sign+' route '+h.routeM.toFixed(2)+' m / entered '+supplied(h).toFixed(2)+' m'+(supplied(h)<h.routeM?' / SHORT '+(h.rou … [line shortened here: 502 characters; full line on GitHub]
function lengthsChanged(){applyLengths();lengthControls();render();electrical?.refresh();}
$('string').onchange=()=>{selected=$('string').value;};
$('length-string').onchange=()=>{selected=$('length-string').value;lengthControls();};
for(const [field,sign]of [['length-plus','+'],['length-minus','-']])$(field).onchange=()=>{const v=Number($(field).value);if(!Number.isFinite(v)||v<0||v>10000){$('error').textContent='Cable length must be 0–10,000 m.';return;}enteredLengths.set($('length-string').value+sign,v);$('error').textContent='';lengthsChanged();};
$('tolerance').onchange=()=>{const v=Number($('tolerance').value);if(!Number.isFinite(v)||v<0||v>50){$('error').textContent='Allowance must be 0–50%.';return;}tolerance=v;$('error').textContent='';lengthsChanged();};
$('length-reset').onclick=()=>{for(const sign of ['+','-'])enteredLengths.delete($('length-string').value+sign);lengthsChanged();};
$('module-source').href=sources.module;$('inverter-source').href=sources.inverter;
$('flow').onclick=()=>{playing=!playing;$('flow').textContent=playing?'Pause flow':'Animate flow';$('flow').setAttribute('aria-pressed',String(playing));};
$('overview').onclick=()=>{$('viewport').classList.remove('desk');setTimeout(()=>fit(),80);};
$('desk').onclick=()=>{$('viewport').classList.add('desk');setTimeout(()=>fit(),80);};
$('ports').onclick=()=>{$('viewport').classList.remove('desk');setTimeout(()=>fit(drawing.shapes.filter(s=>s.role==='inverter'||model.ports.some(p=>p.id===s.node)).flatMap(s=>s.pts)),80);};
$('focus').onclick=()=>{selected=$('string').value;const s=model.strings.find(s=>s.id===selected),hs=model.homes.filter(h=>h.stringId===selected);$('selection').textContent=s.id+' / '+s.side+' / '+(s.connected?'MPPT '+s.mppt+' input '+s.input+' / '+hs.map(h=>h.sign+' '+h.routeM.toFixed(2)+' m').join(' · '):'TO OTHER INVERTER — OFF DRAWING. Excluded from this inverter’s 475.2 kWp.');$('viewport').c … [line shortened here: 549 characters; full line on GitHub]
$('fullscreen').onclick=()=>document.documentElement.requestFullscreen();
$('csv').onclick=()=>save('inverter-48-cable-lengths.csv','text/csv',csv());
$('json').onclick=()=>save('inverter-48-geometry.json','application/json',JSON.stringify(model,null,2));
$('svg').onclick=()=>save('inverter-48-NOT-TO-SCALE.svg','image/svg+xml',svg());
$('rebuild').onclick=()=>{try{const next=build({physicalOffset:Number($('physical-offset').value),drawingOffset:Number($('drawing-offset').value)});model=next;applyLengths();summary();lengthControls();electrical?.refresh();$('error').textContent='';render();}catch(e){$('error').textContent=e.message;}};
function render(){if(!ready)return;win().fireCommand('fire inverter-48 {}',null);setTimeout(()=>fit(),220);}
applyLengths();summary();lengthControls();electrical=mountElectrical($('electrical-hud'),{getModel:()=>model,getCableLength:supplied,onChange:report=>{electricalReport=report;}});
const activeWalks=()=>nativeWalks.filter(w=>(flowScope==='all'||w.stringId===selected)&&!w.open&&w.operatingCurrentA!==0&&!w.invalidOperatingPoint);
window.__inverter48={get model(){return structuredClone(model);},get ready(){return ready;},get playing(){return playing;},get selected(){return selected;},get flowScope(){return flowScope;},get flowStats(){return {...flowStats};},get flowFrames(){return flowFrames;},get pulseCount(){return playing?activeWalks().length*3:0;},selectString(id){if(!model.strings.some(s=>s.id===id))return;selected=id; … [line shortened here: 698 characters; full line on GitHub]
let tries=0;
const poll=setInterval(async()=>{try{
const w=win();if(++tries>300)throw Error('Native renderer did not become ready.');
if(!w.FIRE||!w.fireCommand||!w.eval('typeof N!=="undefined"&&N>0&&typeof lastFire!=="undefined"&&!!lastFire'))return;
clearInterval(poll);nativeAdapter=await createNativeAdapter(w);ready=true;
const style=w.document.createElement('style');style.textContent='#anonymous-project-tools,#manufacturer-tools,#connector-lens,#local-drawing-tools,#series-tools,#foot,#presets,#top,#hud,#say,#card,#kdev{display:none!important}#c{opacity:0}#sldshapes{background:#090c13}';w.document.head.append(style);
const clamp=w.stringClampMicro;w.stringClampMicro=function(){if(w.eval('sldShapes&&sldShapes.inverter48'))return;return clamp.apply(this,arguments);};
w.FIRE.register('inverter-48','48 CABLES / ONE INVERTER',nativeDrawing,[]);w.FIRE_SLD_KIND['inverter-48']='string';w.__wafer.onDraw.add(paint);
let pointerStart=null;
w.document.addEventListener('pointerdown',e=>{pointerStart={x:e.clientX,y:e.clientY};},true);
w.document.addEventListener('pointerup',e=>{
if(!pointerStart||Math.hypot(e.clientX-pointerStart.x,e.clientY-pointerStart.y)>5||e.target.tagName!=='CANVAS'){pointerStart=null;return;}
pointerStart=null;let nearest=null,limit=8;
for(const h of model.homes){const pts=h.drawing.map(map).map(w.shapePoint);for(let i=1;i<pts.length;i++){const a=pts[i-1],b=pts[i],dx=b[0]-a[0],dy=b[1]-a[1],sq=dx*dx+dy*dy,t=sq?Math.max(0,Math.min(1,((e.clientX-a[0])*dx+(e.clientY-a[1])*dy)/sq)):0,d=Math.hypot(e.clientX-a[0]-t*dx,e.clientY-a[1]-t*dy);if(d<limit){limit=d;nearest=h;}}}
if(nearest){selected=nearest.stringId;$('length-string').value=selected;lengthControls();showHud(true);$('length-editor').open=true;$('length-'+(nearest.sign==='+'?'plus':'minus')).focus();$('selection').textContent=nearest.id+' → '+nearest.portId+' | route '+nearest.routeM.toFixed(2)+' m | entered/estimated '+nearest.suppliedLengthM.toFixed(2)+' m';}
},true);
$('loading').hidden=true;$('loading').style.display='none';render();
}catch(e){clearInterval(poll);$('error').textContent=e.message;$('loading').textContent=e.message;}},100);
function drawFlowOverlay(){
if(!ready)return;
const w=win();
for(const walk of nativeWalks){const r=electricalReport?.strings.find(s=>s.id===walk.stringId);walk.operatingCurrentA=r?.currentA??null;walk.invalidOperatingPoint=r?.invalidOperatingPoint??false;}
if(!flowCanvas){flowCanvas=w.document.createElement('canvas');flowCanvas.id='inverter-flow';flowCanvas.style.cssText='position:fixed;inset:0;pointer-events:none;z-index:10';w.document.body.append(flowCanvas);}
const dpr=Math.min(2,w.devicePixelRatio||1),width=w.innerWidth,height=w.innerHeight;
if(flowCanvas.width!==Math.round(width*dpr)||flowCanvas.height!==Math.round(height*dpr)){flowCanvas.width=Math.round(width*dpr);flowCanvas.height=Math.round(height*dpr);flowCanvas.style.width=width+'px';flowCanvas.style.height=height+'px';}
const ctx=flowCanvas.getContext('2d');ctx.setTransform(dpr,0,0,dpr,0,0);ctx.clearRect(0,0,width,height);
flowStats={strings:0,homePaths:0};if(playing&&!document.hidden){flowStats=nativeAdapter?.drawFlow(ctx,activeWalks(),clock,{selected})??{strings:0,homePaths:0};flowFrames++;}
}
let previousFrame=0;
function tick(now){const dt=Math.min(.1,(now-last)/1000);last=now;if(playing&&!document.hidden)clock+=dt;if(now-previousFrame>=50){previousFrame=now;drawFlowOverlay();}requestAnimationFrame(tick);}requestAnimationFrame(tick);
$('flow-scope').onclick=()=>{flowScope=flowScope==='all'?'selected':'all';$('flow-scope').textContent=flowScope==='all'?'All 24 strings':'Selected string';$('flow-scope').setAttribute('aria-pressed',String(flowScope==='all'));$('selection').textContent=flowScope==='all'?'24 connected strings / 48 DC cables. Open or invalid circuits do not animate.':'Following the selected string; all wiring remain … [line shortened here: 414 characters; full line on GitHub]Inverter Station
A JavaScript module in the wiring folder of GlobalGrid2050 that syncs lengths (`syncLengths`) (units: MVA, kVA, mm²), covering transformers, using IEC 60228. Served with the page at https://globalgrid2050.com/ventus/wiring/.
electricalglobalgrid2050 / ventus/wiring/inverter-station.mjs · lines 1–84 of 84 · Not reached from any entry point (candidate for review) · pattern siteModel (shared by 2 files)
- What it does
- It draws transformers. Defines 11 functions or classes, including $, buildStation, el, txt, line. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage sub33kv_design (path word 'inverter'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary. Domain terms in the code: transformers.
- Inputs & outputs
- In: CSV file inverter-station-84-phase-cables.csv.
- What it achieves
- It builds station (`buildStation`), syncs lengths (`syncLengths`) and selects station (`selectStation`). Defines `buildStation`, `txt`, `line` and 6 more. Its code works with 352 kVA and 10 MVA.
- Why it matters
- No other file in the estate was found to import it.
- Application
- globalgrid2050 · ventus/wiring · JavaScript module
- Uses
- none found
- Used by
- none found
- Produces
- sources, buildStation
- Defines here
- $, buildStation, el, txt, line, render, syncLengths, save, svgExport, siteModel, selectStation
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 ventus/wiring/inverter-station.mjs:1-84 · blob 4ec899fdeba276c130852fa098a31035eaecebd6 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: unreached_review
const $=id=>document.getElementById(id),NS='http://www.w3.org/2000/svg';
export const sources={cable:'#drawing-basis',inverter:'#drawing-basis',aluminiumAlpha:'IEC 60228:2004 informative Annex B, printed page 29; general aluminium alpha20 = 0.00403 / K; alloy-specific coefficient requires manufacturer data'};
export function buildStation({feedersPerSection=14,transformerMva=5,areaMm2=400,trenchDepthM=.9,kva=352,lengths={},ambient=30,baseAmpacity=null,derating=1,r20=.0778,conductorTemp=20,alpha=.00403,racFactor=null,reactance=null,pf=1}={}) {
if(!Number.isInteger(feedersPerSection)||feedersPerSection<1||feedersPerSection>20||!Number.isFinite(transformerMva)||transformerMva<=0||transformerMva>100||!Number.isFinite(areaMm2)||areaMm2<16||areaMm2>1000||!Number.isFinite(trenchDepthM)||trenchDepthM<.1||trenchDepthM>5)throw Error('Invalid station geometry');
if(![352,320,295].includes(kva)||!Number.isFinite(ambient)||ambient< -40||ambient>90||!Number.isFinite(derating)||derating<=0||derating>1)throw Error('Station input outside supported range');
if(baseAmpacity!==null&&(!Number.isFinite(baseAmpacity)||baseAmpacity<=0||baseAmpacity>5000))throw Error('Base ampacity must be positive');
for(const [v,min,max]of [[r20,.0001,10],[conductorTemp,-40,90],[alpha,0,.01],[pf,.01,1]])if(!Number.isFinite(v)||v<min||v>max)throw Error('Conductor calculation input outside range');
if(racFactor!==null&&(!Number.isFinite(racFactor)||racFactor<1||racFactor>10)||reactance!==null&&(!Number.isFinite(reactance)||reactance<0||reactance>10))throw Error('AC resistance or reactance input outside range');
const rTheta=r20*(1+alpha*(conductorTemp-20));
const inverters=[],cables=[],sections=[],lineCurrent=kva*1000/(Math.sqrt(3)*800);
for(let s=0;s<2;s++){
const sectionId='LV-'+(s+1),ids=[];
for(let i=0;i<feedersPerSection;i++){
const id='INV-'+String(s*feedersPerSection+i+1).padStart(2,'0');ids.push(id);inverters.push({id,sectionId,model:'352 kVA inverter',kva,lineCurrentA:lineCurrent});
for(let p=1;p<=3;p++){const cableId=id+'-L'+p,value=lengths[cableId]??0;if(!Number.isFinite(value)||value<0||value>10000)throw Error('Cable length outside range');const rdc=value?rTheta*value/1000:null;cables.push({id:cableId,inverterId:id,sectionId,phase:'L'+p,areaMm2,trenchDepthM,shieldMm2:39,material:'Al',part:'reference',lengthM:value||null,ambientC:ambient,baseAmpacityA:baseAmpacity,derati … [line shortened here: 645 characters; full line on GitHub]
}
sections.push({id:sectionId,inverters:ids,phases:['L1','L2','L3'],busRatingA:4000,lineCurrentA:feedersPerSection*lineCurrent,kva:feedersPerSection*kva,transformer:'TX-'+(s+1),transformerRatingKva:transformerMva*1000});
}
const feeders=inverters.map(inv=>{const cs=cables.filter(c=>c.inverterId===inv.id),complete=cs.every(c=>c.lengthM!==null),balanced=complete&&cs.every(c=>Math.abs(c.lengthM-cs[0].lengthM)<1e-8),delta=balanced&&racFactor!==null&&reactance!==null?Math.sqrt(3)*lineCurrent*cs[0].lengthM/1000*(rTheta*racFactor*pf+reactance*Math.sqrt(1-pf*pf)):null;return {id:inv.id,complete,balanced,dcResistanceLossW:c … [line shortened here: 623 characters; full line on GitHub]
return {design:{feedersPerSection,transformerMva,areaMm2,trenchDepthM},schema:'VENTUS.inverter-station/1',voltageLL:800,kvaPerInverter:kva,inverters,cables,feeders,sections,transformers:sections.map(s=>({id:s.transformer,from:s.id,ratedKva:transformerMva*1000,connectedKva:s.kva})),totalMva:2*feedersPerSection*kva/1000,lineCurrentA:lineCurrent,ambientC:ambient,baseAmpacityA:baseAmpacity,derating,e … [line shortened here: 759 characters; full line on GitHub]
}
let design={feedersPerSection:14,transformerMva:5,areaMm2:400,trenchDepthM:.9};
let entered={},playing=true,model=buildStation(design);
const el=(name,attrs={},text)=>{const e=document.createElementNS(NS,name);for(const [k,v]of Object.entries(attrs))e.setAttribute(k,v);if(text!==undefined)e.textContent=text;return e;};
const txt=(parent,text,x,y,size=13,fill)=>{const e=el('text',{x,y,'font-size':size,...(fill?{style:'fill:'+fill}:{})},text);parent.append(e);};
function line(parent,d,attrs={}){const e=el('path',{d,fill:'none',stroke:'#9db7cb','stroke-width':2,...attrs});parent.append(e);return e;}
function render(){
const svg=$('drawing');svg.replaceChildren();svg.classList.toggle('paused',!playing);
const defs=el('defs'),filter=el('filter',{id:'neon',filterUnits:'userSpaceOnUse',x:0,y:0,width:2000,height:930});filter.append(el('feGaussianBlur',{stdDeviation:2,result:'blur'}));const merge=el('feMerge');merge.append(el('feMergeNode',{in:'blur'}),el('feMergeNode',{in:'SourceGraphic'}));filter.append(merge);defs.append(filter);const arrow=el('marker',{id:'power-arrow',viewBox:'0 0 10 10',refX:8, … [line shortened here: 617 characters; full line on GitHub]
txt(svg,model.inverters.length+' x '+model.kvaPerInverter+' kVA / 800 V THREE-PHASE AC',40,32,18,'#8edfe7');txt(svg,'NOT TO SCALE',1730,32,23,'#b9b6ab');
const colours=['#ff927a','#c6ceda','#81cce8'];
model.sections.forEach((section,s)=>{
const top=75+s*415;txt(svg,'SECTION '+(s+1)+' / '+section.inverters.length+' INVERTERS / '+(section.inverters.length*3)+' PHASE CABLES',40,top,18,'#95e3e7');
for(let p=0;p<3;p++){const by=top+222+p*22,elbow=1690-p*20;line(svg,'M55 '+by+' H'+elbow+' V'+(top+280+p*24)+' H1710',{stroke:colours[p],'stroke-width':6,'data-bus-phase':section.id+'-L'+(p+1)});line(svg,'M'+(elbow+3)+' '+(top+280+p*24)+' H1704',{stroke:'#b8f5fa','stroke-width':1.5,'marker-end':'url(#power-arrow)'});txt(svg,'L'+(p+1),19,by+5,13,colours[p]);}
section.inverters.forEach((id,i)=>{
const x=45+i*(1568/section.inverters.length),y=top+35;svg.append(el('rect',{x,y,width:92,height:83,rx:2,fill:'#111c28',stroke:'#8ba6bb','data-inverter':id}));
txt(svg,id,x+8,y+20,13);txt(svg,'352 kVA inverter',x+8,y+38,11);txt(svg,model.kvaPerInverter+' kVA',x+8,y+56,11);txt(svg,model.lineCurrentA.toFixed(1)+' A',x+8,y+73,11,'#8edfe7');
for(let p=0;p<3;p++){const px=x+23+p*23,end=top+222+p*22,d='M'+px+' '+(y+83)+' V'+end,cable=model.cables.find(c=>c.id===id+'-L'+(p+1));
line(svg,d,{stroke:'#090c13','stroke-width':6});line(svg,d,{stroke:colours[p],'stroke-width':2,'data-cable':cable.id});line(svg,d,{class:'power','aria-hidden':'true'});
svg.append(el('circle',{cx:px,cy:end,r:4,fill:colours[p]}));txt(svg,'L'+(p+1),px-8,y+99,9,colours[p]);
const label=el('text',{x:px-4,y:end-8,transform:'rotate(-90 '+(px-4)+' '+(end-8)+')','font-size':10,'data-length-label':cable.id,style:'fill:'+colours[p]+';paint-order:stroke;stroke:#090c13;stroke-width:3;stroke-linejoin:round;pointer-events:none'},cable.lengthM===null?'ENTER m':cable.lengthM+' m · entered');svg.append(label);
const hit=el('rect',{x:px-8,y:y+83,width:16,height:end-y-83,fill:'transparent','data-edit-cable':cable.id,role:'button',tabindex:0,'aria-label':'Edit '+cable.id+' entered length',style:'cursor:pointer;pointer-events:all'});svg.append(hit);hit.append(el('title',{},cable.id+' · '+(cable.lengthM===null?'length not entered':'entered '+cable.lengthM+' m')+' · click to edit'));hit.onclick=()=>{$('in … [line shortened here: 729 characters; full line on GitHub]
}
});
txt(svg,'3 × 1C 400 mm² Al PER INVERTER / SELECT A FEEDER IN THE HUD TO ENTER LENGTHS',45,top+21,11,'#809cad');
txt(svg,section.id+' / 4,000 A THREE-PHASE ASSEMBLY',45,top+310,17,'#a5e3e8');
txt(svg,section.lineCurrentA.toFixed(2)+' A RMS PER PHASE / '+(section.kva/1000).toFixed(3)+' MVA CONNECTED',45,top+337,15);
txt(svg,(section.lineCurrentA/4000*100).toFixed(2)+'% OF STATED BUS RATING / PROTECTION AND INSTALLATION NOT ASSESSED',45,top+361,11,'#97aabc');
const ty=top+235;svg.append(el('rect',{x:1710,y:ty,width:245,height:150,rx:3,fill:'#101c29',stroke:'#89a9bd','data-transformer':section.transformer}));txt(svg,section.transformer+' / TRANSFORMER',1727,ty+25,16,'#99e1e7');
for(let p=0;p<3;p++){svg.append(el('circle',{cx:1748,cy:ty+53+p*24,r:10,fill:'none',stroke:colours[p],'stroke-width':2}),el('circle',{cx:1760,cy:ty+53+p*24,r:10,fill:'none',stroke:colours[p],'stroke-width':2}));}
txt(svg,(section.kva/1000).toFixed(3)+' MVA',1786,ty+64,16);txt(svg,'CONNECTED INPUT',1786,ty+82,11);txt(svg,model.design.transformerMva+' MVA ASSUMED RATING',1727,ty+130,11);txt(svg,'HV / VECTOR: UNASSIGNED',1727,ty+145,11);
});
txt(svg,'NEON = AVERAGE AC POWER DIRECTION TOWARD THE BUSBARS. AC ELECTRONS OSCILLATE; THESE ARE NOT ELECTRON TRAJECTORIES.',40,900,12,'#83bdcc');
$('total-rating').textContent=(20*model.design.transformerMva)+' MVA site / '+(2*model.design.transformerMva)+' MVA station';
$('arithmetic').textContent='I = S / (√3 × 800 V) = '+model.lineCurrentA.toFixed(3)+' A per inverter; '+model.design.feedersPerSection+' x I = '+model.sections[0].lineCurrentA.toFixed(2)+' A per phase per section. Each section: '+(model.sections[0].kva/1000).toFixed(3)+' MVA.';
$('ampacity-result').textContent=model.baseAmpacityA===null?'Cable ampacity: unresolved. No installation rating entered.':'Entered base × factor = '+(model.baseAmpacityA*model.derating).toFixed(1)+' A; nameplate-current margin '+(model.baseAmpacityA*model.derating-model.lineCurrentA).toFixed(1)+' A. Input comparison only; suitability unresolved.';
lossReadout();
}
function lossReadout(){const id=$('inverter').value,f=model.feeders.find(f=>f.id===id),cs=model.cables.filter(c=>c.inverterId===id);if(!f)return;$('loss-result').textContent=cs.map(c=>c.phase+': '+(c.resistanceDcOhm===null?'length unknown':c.resistanceDcOhm.toFixed(5)+' Ω; I²Rdc '+c.dcResistanceLossW.toFixed(1)+' W'+(c.acResistanceLossW===null?'':'; I²Rac '+c.acResistanceLossW.toFixed(1)+' W'))).j … [line shortened here: 804 characters; full line on GitHub]
function rebuild(){try{model=buildStation({...design,kva:Number($('rating').value),lengths:entered,ambient:Number($('ambient').value),baseAmpacity:$('ampacity').value===''?null:Number($('ampacity').value),derating:Number($('derating').value),r20:Number($('r20').value),conductorTemp:Number($('conductor-temp').value),alpha:Number($('alpha').value),racFactor:$('rac').value===''?null:Number($('rac').v … [line shortened here: 685 characters; full line on GitHub]
function syncLengths(){for(let p=1;p<=3;p++)$('len'+p).value=entered[$('inverter').value+'-L'+p]??0;lossReadout();}
function save(name,type,data){const a=document.createElement('a'),u=URL.createObjectURL(new Blob([data],{type}));a.href=u;a.download=name;a.click();setTimeout(()=>URL.revokeObjectURL(u),1000);}
function svgExport(){const copy=$('drawing').cloneNode(true);copy.querySelectorAll('.power').forEach(e=>e.remove());copy.setAttribute('width','3000');copy.setAttribute('height','1395');const style=el('style',{},'text{font-family:Consolas,monospace;fill:#bbd0e1}');copy.prepend(style);return new XMLSerializer().serializeToString(copy);}
function csv(){return 'cable,inverter,section,phase,area_mm2,material,length_m,current_A,ambient_C,base_ampacity_A,derating,derated_ampacity_A,Rdc_ohm,I2Rdc_W,I2Rac_W,conductor_C,R20_ohm_km,alpha_per_K,Rac_factor,reactance_ohm_km,power_factor\n'+model.cables.map(c=>[c.id,c.inverterId,c.sectionId,c.phase,c.areaMm2,c.material,c.lengthM??'',c.currentA.toFixed(6),c.ambientC,c.baseAmpacityA??'',c.derat … [line shortened here: 714 characters; full line on GitHub]
for(const inv of model.inverters)$('inverter').add(new Option(inv.id+' · '+inv.sectionId,inv.id));$('inverter').onchange=syncLengths;
for(let p=1;p<=3;p++)$('len'+p).onchange=()=>{entered[$('inverter').value+'-L'+p]=Number($('len'+p).value);rebuild();};
for(const id of ['rating','ambient','ampacity','derating','r20','conductor-temp','alpha','rac','reactance','pf'])$(id).onchange=rebuild;
$('controls').onclick=()=>{$('toolbar').hidden=!$('toolbar').hidden;$('controls').setAttribute('aria-expanded',String(!$('toolbar').hidden));};
$('analysis').onclick=()=>{$('hud').hidden=!$('hud').hidden;$('analysis').setAttribute('aria-expanded',String(!$('hud').hidden));};$('close-hud').onclick=()=>{$('hud').hidden=true;$('analysis').setAttribute('aria-expanded','false');};
$('whole').onclick=()=>$('viewport').classList.remove('large');$('large').onclick=()=>$('viewport').classList.add('large');$('flow').onclick=()=>{playing=!playing;$('flow').textContent=playing?'Pause power flow':'Animate power flow';render();};$('fullscreen').onclick=()=>document.documentElement.requestFullscreen();
$('save-svg').onclick=()=>save('inverter-station-NOT-TO-SCALE.svg','image/svg+xml',svgExport());$('save-csv').onclick=()=>save('inverter-station-84-phase-cables.csv','text/csv',csv());
$('cable-source').href=sources.cable;$('inverter-source').href=sources.inverter;syncLengths();render();window.__inverterStation={get model(){return structuredClone(model);},buildStation,csv,svg:svgExport};
// Ten repeated generic station blocks; no surveyed layout or confidential data.
let selectedStation=1;
function siteModel(){return {stationCount:10,transformerCount:20,transformerCapacityMva:20*model.design.transformerMva,inverterCount:10*model.inverters.length,acPhaseCableCount:10*model.cables.length,trenchDepthM:model.design.trenchDepthM,phaseConductorAreaMm2:model.design.areaMm2,hvVoltageKv:33,hvAreaMm2:1000,connectedInverterMva:10*model.totalMva};}
function selectStation(id){selectedStation=id;document.querySelectorAll('[data-station]').forEach(b=>b.setAttribute('aria-pressed',String(Number(b.dataset.station)===id)));$('station-selected').textContent='STATION '+id+' / 10 | 2 x '+model.design.transformerMva+' MVA | '+model.inverters.length+' inverters | '+model.cables.length+' AC phase cables';render();}
const overview=$('station-overview');
for(let i=1;i<=10;i++){const button=document.createElement('button');button.dataset.station=i;button.textContent=String(i).padStart(2,'0')+' · 10 MVA';button.onclick=()=>selectStation(i);overview.append(button);}
Object.defineProperties(window.__inverterStation,{site:{get:siteModel},selectedStation:{get:()=>selectedStation}});selectStation(1);
const trench=document.createElement('p');trench.id='trench-default';trench.style.cssText='margin:4px 12px;font:12px monospace;flex-shrink:0';trench.textContent='AC trench depth 0.90 m ? each inverter: 3 ? 400 mm? Al ? 352 kVA at 800 V ? cable spacing, cover and installation rating not assigned';document.querySelector('header').after(trench);
window.__inverterStation.setDesign=value=>{const next={...design,...value};buildStation(next);design=next;entered={};rebuild();$('inverter').replaceChildren(...model.inverters.map(i=>new Option(i.id,i.id)));syncLengths();selectStation(selectedStation);document.querySelectorAll('[data-station]').forEach(b=>b.textContent=b.dataset.station+' | '+(2*design.transformerMva)+' MVA');};Cpu Ref
A Python command-line tool in the solar billion folder of GPU Drivers for Global Grid that works with known answers (`known_answers`) (units: kW), covering cables.
ingestgpu-drivers-for-global-grid / cuda-maths/solar-billion/cpu_ref.py · lines 1–116 of 116 · Entry point · pattern evaluate (shared by 18 files)
- What it does
- Defines decode, evaluate, known_answers. Uses libraries math, solar_core.
- Why it exists in the grid workflow
- Domain stage sub33kv_design (path word 'solar'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary. Domain terms in the code: cables. README: "Files: `solar-billion/` — `cpu_ref.py` (scalar reference), `cpu_vec.py` (vectorised, multiprocess), `gpu_vec.py` (CuPy), `main.py`, plus `FORMULA.txt` and `RESULTS.txt` with the full verdict counts."
- Downstream impact
- It is itself an entry point (Python CLI); no other file was found loading it.
- What it achieves
- It is built from the decode step (`decode`) and the evaluate step (`evaluate`). The plain scalar reference. Clear and slow. Its code works with 356.07 kW.
- Why it matters
- No other file in the estate was found to import it; it is an entry point.
- Application
- gpu-drivers-for-global-grid · cuda-maths/solar-billion · Python CLI
- Uses
- math, solar_core
- Used by
- none found
- Produces
- decode, evaluate, known_answers
- Defines here
- decode, evaluate, known_answers
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- gpu-drivers-for-global-grid@6c47912a8dde251ffebd92ff129e6a0c11c4ebfe cuda-maths/solar-billion/cpu_ref.py:1-116 · blob 8d84c12a419c7c8f3ca93e7bb9c24e0f49915faf · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: unknown
# cpu_ref.py - the plain scalar reference. Clear and slow. Everything else on this
# job is checked against this file. One CASE evaluated end to end from closed forms.
import math
from solar_core import *
AV = axis_values()
def decode(i):
d = []
for r in RADIX:
d.append(i % r); i //= r
return d
def evaluate(idx):
(dc, dN, dSp, dw, dld, dst, dL, dTc, dTmin, dTh, dbif, dRc) = decode(idx)
cid, Voc, Vmp, Isc, Imp, beta, gamma, a_isc, fuse, pmax, wm, lm = CLASSES[dc]
N = AV["N"][dN]
Sp = AV["Sp"][dSp]
wir = dw
lead = AV["lead"][dld]
site = AV["site"][dst]
L = AV["L"][dL]
Tc = AV["Tcond"][dTc]
Tmin = AV["Tmin"][dTmin]
Thot = AV["Thot"][dTh]
bif = AV["bif"][dbif]
Rc = AV["Rc"][dRc]
# ---- 1. cold open-circuit voltage, BOTH readings of the disputed clause ----
# reading A: the site minimum with the +10 K allowance -> Tdesign = Tmin + 10
# reading B: the site minimum with no allowance -> Tdesign = Tmin
VocA = N * Voc * (1.0 + beta / 100.0 * ((Tmin + T_ALLOW_K) - 25.0))
VocB = N * Voc * (1.0 + beta / 100.0 * (Tmin - 25.0))
# ---- 2. maximum-power voltage at the hot cell temperature ----
VmpHot = N * Vmp * (1.0 + gamma / 100.0 * (Thot - 25.0))
VmpStc = N * Vmp
# ---- 3. design current ----
Idesign = 1.25 * bif * Isc
Itrack = Sp * Idesign
Iop = bif * Imp # operating current for the loss terms
# ---- 4. fuse question ----
fault = (Sp - 1) * 1.25 * Isc
fuse_needed = (Sp >= 3) or (fault > fuse)
# ---- 5. geometry and series resistance ----
p = wm + GAP_M
if wir == 0: # sequential
lead_per_mod = LEAD_POS_M + LEAD_NEG_M
site_return = (N - 2) * p + BOX_S_M
elif wir == 1: # leapfrog, two lead lengths
lead_per_mod = 2.0 * p + 2.0 * SLACK_M
site_return = 0.0
else: # leapfrog, alternate modules turned
lead_per_mod = (2.0 * p - BOX_S_M) + 2.0 * SLACK_M
site_return = 0.0
lead_m = N * lead_per_mod
home_m = 2.0 * L # positive and negative home run
site_m = site_return + home_m
pairs = N + 1
k = 1.0 + ALPHA_CU * (Tc - 20.0)
r_lead = R20[int(lead)] / 1000.0 * k
r_site = R20[int(site)] / 1000.0 * k
R = r_lead * lead_m + r_site * site_m + pairs * Rc
vdrop = Iop * R
vdrop_p = vdrop / VmpHot * 100.0
loss_p = vdrop / VmpStc * 100.0
# ---- 6. the verdict: the FIRST rule that fails ----
if VocA > V_SYS_MAX: verdict = 1
elif VmpHot < MPPT_MIN_V: verdict = 3
elif Idesign > A_CONNECTOR: verdict = 4
elif Itrack > A_TRACKER: verdict = 5
elif vdrop_p > VDROP_CAP: verdict = 6
elif VocB > V_SYS_MAX: verdict = 2
else: verdict = 0
return dict(idx=idx, cls=cid, N=N, Sp=Sp, wiring=WIRING[wir], lead=lead, site=site,
L=L, Tcond=Tc, Tmin=Tmin, Thot=Thot, bif=bif, Rc=Rc,
VocA=VocA, VocB=VocB, VmpHot=VmpHot, Idesign=Idesign, Itrack=Itrack,
fuse_needed=fuse_needed, R=R, vdrop_pct=vdrop_p, loss_pct=loss_p,
lead_m=lead_m, site_m=site_m, pairs=pairs, verdict=verdict)
NUM_KEYS = ["VocA", "VocB", "VmpHot", "Idesign", "Itrack", "R", "vdrop_pct",
"loss_pct", "lead_m", "site_m"]
def known_answers():
"""Check the closed forms against the library's published answers."""
out = []
# 30 x 45.9 V at -0.25 %/K, site minimum -10 C:
# with the +10 K allowance -> 1463.06 V ; without it -> about 1497.4 V
a = 30 * 45.9 * (1 + (-0.25) / 100 * ((-10 + 10) - 25))
b = 30 * 45.9 * (1 + (-0.25) / 100 * (-10 - 25))
out.append(("cold Voc with +10 K allowance = 1463.06 V", a, 1463.0625, abs(a - 1463.0625) < 5e-3))
out.append(("cold Voc without the allowance = 1497.4 V", b, 1497.4, abs(b - 1497.4) < 0.1))
# block DC 356.07 kW = 24 strings x 30 modules x 495 W class
kw = 24 * 30 * 495 / 1000.0
out.append(("block DC = 356.07 kW (24 x 30 x 495 W)", kw, 356.4, abs(kw - 356.4) < 0.5))
# sequential lead 0.63 m/module; turned leapfrog 2.006 m; two-lead 2.846 m (p=1.323)
p = 1.303 + GAP_M
out.append(("sequential lead 0.63 m a module", LEAD_POS_M + LEAD_NEG_M, 0.63, True))
out.append(("turned-leapfrog lead 2.006 m a module", (2 * p - BOX_S_M) + 0.2, 2.006, abs((2 * p - BOX_S_M) + 0.2 - 2.006) < 1e-9))
out.append(("two-lead leapfrog 2.846 m a module", 2 * p + 0.2, 2.846, abs(2 * p + 0.2 - 2.846) < 1e-9))
# site cable saved per string (N-2)p + b = 37.884 m at N = 30
sv = (30 - 2) * p + BOX_S_M
out.append(("site cable saved a string 37.884 m", sv, 37.884, abs(sv - 37.884) < 1e-9))
return out
if __name__ == "__main__":
for name, got, want, ok in known_answers():
print(("PASS " if ok else "FAIL ") + name + " got %.4f" % got)
print(evaluate(123456789))Cpu Vec
A Python module in the solar billion folder of GPU Drivers for Global Grid that builds tables (`build_tables`), aggregates np (`aggregate_np`) and runs multiproc (`run_multiproc`).
transformgpu-drivers-for-global-grid / cuda-maths/solar-billion/cpu_vec.py · lines 1–137 of 137 · Not reached from any entry point (candidate for review) · pattern build_tables (shared by 2 files)
- What it does
- It calculates its inputs. Defines 6 functions or classes, including _tab, build_tables, kernel, aggregate_np, _worker. Uses libraries numpy, solar_core, ctypes, concurrent.futures.
- Why it exists in the grid workflow
- Domain stage sub33kv_design (path word 'solar'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary. README: "Files: `solar-billion/` — `cpu_ref.py` (scalar reference), `cpu_vec.py` (vectorised, multiprocess), `gpu_vec.py` (CuPy), `main.py`, plus `FORMULA.txt` and `RESULTS.txt` with the full verdict counts."
- Downstream impact
- Used directly by 1 file: GPU Vec (gpu-drivers-for-global-grid).
- What it achieves
- It is built from the kernel step (`kernel`). The same arithmetic as `cpu_ref.py`, NumPy-vectorised over mixed-radix indices, and a multi-process driver capped at 12 workers below normal priority.
- Why it matters
- Imported by GPU Vec.
- Application
- gpu-drivers-for-global-grid · cuda-maths/solar-billion · Python module
- Uses
- numpy, solar_core, ctypes, concurrent.futures
- Used by
- imported by GPU Vec (import)
- Produces
- build_tables, kernel, aggregate_np, run_multiproc
- Defines here
- _tab, build_tables, kernel, aggregate_np, _worker, run_multiproc
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- gpu-drivers-for-global-grid@6c47912a8dde251ffebd92ff129e6a0c11c4ebfe cuda-maths/solar-billion/cpu_vec.py:1-137 · blob 91f2c874edfba46c1435bb353eb9b7c1547009e6 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: unreached_review
# cpu_vec.py - the same arithmetic as cpu_ref.py, NumPy-vectorised over mixed-radix
# indices, and a multi-process driver capped at 12 workers below normal priority.
import numpy as np
from solar_core import *
_AV = axis_values()
def _tab(xp, name):
return xp.asarray(_AV[name], dtype=xp.float64)
def build_tables(xp):
"""Every axis as a lookup table, so the kernel is pure gather + arithmetic."""
C = np.array([[c[1], c[2], c[3], c[4], c[5], c[6], c[8], c[9], c[10]] for c in CLASSES],
dtype=np.float64) # Voc Vmp Isc Imp beta gamma fuse pmax width
T = dict(C=xp.asarray(C))
for k in ("N", "Sp", "lead", "site", "L", "Tcond", "Tmin", "Thot", "bif", "Rc"):
T[k] = _tab(xp, k)
T["R20"] = xp.asarray([R20[4], R20[6], R20[10]], dtype=xp.float64)
T["Lband"] = xp.asarray(L_BAND_EDGES, dtype=xp.float64)
return T
def kernel(xp, T, idx):
"""idx: int64 array of linear case indices -> (verdict, packed, cell, outputs)."""
i = idx
dc = (i % RADIX[0]).astype(xp.int64); i = i // RADIX[0]
dN = (i % RADIX[1]).astype(xp.int64); i = i // RADIX[1]
dSp = (i % RADIX[2]).astype(xp.int64); i = i // RADIX[2]
dw = (i % RADIX[3]).astype(xp.int64); i = i // RADIX[3]
dld = (i % RADIX[4]).astype(xp.int64); i = i // RADIX[4]
dst = (i % RADIX[5]).astype(xp.int64); i = i // RADIX[5]
dL = (i % RADIX[6]).astype(xp.int64); i = i // RADIX[6]
dTc = (i % RADIX[7]).astype(xp.int64); i = i // RADIX[7]
dTn = (i % RADIX[8]).astype(xp.int64); i = i // RADIX[8]
dTh = (i % RADIX[9]).astype(xp.int64); i = i // RADIX[9]
dbf = (i % RADIX[10]).astype(xp.int64); i = i // RADIX[10]
dRc = (i % RADIX[11]).astype(xp.int64)
C = T["C"]
Voc = C[dc, 0]; Vmp = C[dc, 1]; Isc = C[dc, 2]; Imp = C[dc, 3]
beta = C[dc, 4]; gamma = C[dc, 5]; fuse = C[dc, 6]; wm = C[dc, 8]
N = T["N"][dN]; Sp = T["Sp"][dSp]
L = T["L"][dL]; Tc = T["Tcond"][dTc]; Tmin = T["Tmin"][dTn]
Thot = T["Thot"][dTh]; bif = T["bif"][dbf]; Rc = T["Rc"][dRc]
VocA = N * Voc * (1.0 + beta / 100.0 * ((Tmin + T_ALLOW_K) - 25.0))
VocB = N * Voc * (1.0 + beta / 100.0 * (Tmin - 25.0))
VmpHot = N * Vmp * (1.0 + gamma / 100.0 * (Thot - 25.0))
VmpStc = N * Vmp
Idesign = 1.25 * bif * Isc
Itrack = Sp * Idesign
Iop = bif * Imp
fault = (Sp - 1.0) * 1.25 * Isc
fuse_needed = (Sp >= 3.0) | (fault > fuse)
p = wm + GAP_M
seq = (dw == 0); lf = (dw == 1)
lead_per_mod = xp.where(seq, LEAD_POS_M + LEAD_NEG_M,
xp.where(lf, 2.0 * p + 2.0 * SLACK_M,
(2.0 * p - BOX_S_M) + 2.0 * SLACK_M))
site_return = xp.where(seq, (N - 2.0) * p + BOX_S_M, 0.0)
lead_m = N * lead_per_mod
home_m = 2.0 * L
site_m = site_return + home_m
pairs = N + 1.0
k = 1.0 + ALPHA_CU * (Tc - 20.0)
r_lead = T["R20"][dld] / 1000.0 * k
r_site = T["R20"][dst] / 1000.0 * k
R = r_lead * lead_m + r_site * site_m + pairs * Rc
vdrop = Iop * R
vdrop_p = vdrop / VmpHot * 100.0
loss_p = vdrop / VmpStc * 100.0
v = xp.zeros(idx.shape, dtype=xp.int8)
v = xp.where(VocB > V_SYS_MAX, xp.int8(2), v)
v = xp.where(vdrop_p > VDROP_CAP, xp.int8(6), v)
v = xp.where(Itrack > A_TRACKER, xp.int8(5), v)
v = xp.where(Idesign > A_CONNECTOR, xp.int8(4), v)
v = xp.where(VmpHot < MPPT_MIN_V, xp.int8(3), v)
v = xp.where(VocA > V_SYS_MAX, xp.int8(1), v)
# design-surface cell: (class, Tmin, Thot, home-run band, site size)
band = ((L >= T["Lband"][0]).astype(xp.int64) + (L >= T["Lband"][1]).astype(xp.int64)
+ (L >= T["Lband"][2]).astype(xp.int64) + (L >= T["Lband"][3]).astype(xp.int64))
cell = (((dc * 7 + dTn) * 8 + dTh) * 5 + band) * 3 + dst
metres = lead_m + site_m
packed = ((dN + 20) << 44) | ((0x0FFFFFFF - (metres * 10.0 + 0.5).astype(xp.int64)) << 16) \
| (dw << 8) | (dld << 4) | dSp.astype(xp.int64)
packed = xp.where(v == 0, packed, xp.int64(0))
outs = dict(VocA=VocA, VocB=VocB, VmpHot=VmpHot, Idesign=Idesign, Itrack=Itrack,
R=R, vdrop_pct=vdrop_p, loss_pct=loss_p, lead_m=lead_m, site_m=site_m,
fuse=fuse_needed)
return v, packed, cell, outs
def aggregate_np(idx):
"""counts per verdict + best packed design per cell, on the CPU."""
T = build_tables(np)
v, packed, cell, _ = kernel(np, T, idx)
counts = np.bincount(v.astype(np.int64), minlength=len(VERDICTS))
best = np.zeros(N_CELLS, dtype=np.int64)
good = packed > 0
if good.any():
np.maximum.at(best, cell[good], packed[good])
return counts, best
def _worker(args):
start, n, stride, offset = args
try: # below-normal priority: the owner's ceiling is 50% of the machine
import ctypes
ctypes.windll.kernel32.SetPriorityClass(
ctypes.windll.kernel32.GetCurrentProcess(), 0x00004000)
except Exception:
pass
idx = ((np.arange(start, start + n, dtype=np.int64) * stride + offset) % SPACE)
return aggregate_np(idx)
def run_multiproc(total, workers=12, stride=1, offset=0, chunk=1 << 20):
"""Enumerate `total` cases over at most `workers` processes."""
from concurrent.futures import ProcessPoolExecutor
jobs = []
done = 0
while done < total:
n = min(chunk, total - done)
jobs.append((done, n, stride, offset))
done += n
counts = np.zeros(len(VERDICTS), dtype=np.int64)
best = np.zeros(N_CELLS, dtype=np.int64)
with ProcessPoolExecutor(max_workers=workers) as ex:
for c, b in ex.map(_worker, jobs, chunksize=1):
counts += c
np.maximum(best, b, out=best)
return counts, bestGPU Vec
A Python module in the solar billion folder of GPU Drivers for Global Grid that aggregates batch (`aggregate_batch`).
transformgpu-drivers-for-global-grid / cuda-maths/solar-billion/gpu_vec.py · lines 1–57 of 57 · Not reached from any entry point (candidate for review) · pattern detail (shared by 2 files)
- What it does
- It calculates its inputs. Defines tables, free_batch, aggregate_batch, run, detail. Uses libraries numpy, cupy, solar_core, cupyx.
- Why it exists in the grid workflow
- Domain stage sub33kv_design (path word 'solar'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary. README: "Why this one works: the reduction happens on the card (`gpu_vec.py`) so only about 20 kB returns per batch, and the batch is sized from free VRAM at run time rather than hard-coded."
- What it achieves
- It is built from the tables step (`tables`), the free batch helper (`free_batch`) and the run step (`run`). The SAME arithmetic on the GPU with CuPy (the backend the GPU-bench agent got working on this card: cupy-cuda12x 14.2.0, `sm_120`). float64 throughout so it can be held to 1e-9 of the scalar reference.
- Why it matters
- No other file in the estate was found to import it.
- Application
- gpu-drivers-for-global-grid · cuda-maths/solar-billion · Python module
- Uses
- Cpu Vec (import), numpy, cupy, solar_core, cupyx
- Used by
- none found
- Produces
- tables, free_batch, aggregate_batch, run, detail
- Defines here
- tables, free_batch, aggregate_batch, run, detail
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- gpu-drivers-for-global-grid@6c47912a8dde251ffebd92ff129e6a0c11c4ebfe cuda-maths/solar-billion/gpu_vec.py:1-57 · blob d110ef1b8dbcd0cf1596ae5461ff02672ae68426 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: unreached_review
# gpu_vec.py - the SAME arithmetic on the GPU with CuPy (the backend the GPU-bench
# agent got working on this card: cupy-cuda12x 14.2.0, sm_120). float64 throughout so
# it can be held to 1e-9 of the scalar reference. Everything is reduced ON the card:
# only 7 counts and 2520 packed int64s ever come back - about 20 kB a batch.
import numpy as np
import cupy as cp
from solar_core import *
from cpu_vec import build_tables, kernel
_T = None
def tables():
global _T
if _T is None:
_T = build_tables(cp)
return _T
def free_batch(target_frac=0.25, cap=1 << 23):
"""Batch sized to the FREE VRAM - the card is shared with other people's servers."""
free, _tot = cp.cuda.Device(0).mem_info
per_case = 8 * 22 # ~22 live float64/int64 temporaries a case
n = int(free * target_frac / per_case)
n = 1 << max(16, min(int(np.log2(max(n, 1 << 16))), int(np.log2(cap))))
return n
def aggregate_batch(idx_gpu, counts, best):
from cupyx import scatter_max
T = tables()
v, packed, cell, _ = kernel(cp, T, idx_gpu)
counts += cp.bincount(v.astype(cp.int64), minlength=len(VERDICTS))
good = packed > 0
if bool(good.any()):
scatter_max(best, cell[good], packed[good])
def run(total, stride=1, offset=0, batch=None, report=None):
"""Enumerate `total` cases on the GPU. Returns (counts, best) as NumPy."""
batch = batch or free_batch()
counts = cp.zeros(len(VERDICTS), dtype=cp.int64)
best = cp.zeros(N_CELLS, dtype=cp.int64)
done = 0
while done < total:
n = min(batch, total - done)
idx = (cp.arange(done, done + n, dtype=cp.int64) * stride + offset) % SPACE
aggregate_batch(idx, counts, best)
done += n
if report:
report(done)
cp.cuda.Stream.null.synchronize()
return cp.asnumpy(counts), cp.asnumpy(best), batch
def detail(idx_np):
"""Full per-case outputs for the VERIFY step (small arrays only)."""
T = tables()
idx = cp.asarray(idx_np)
v, packed, cell, outs = kernel(cp, T, idx)
o = {k: cp.asnumpy(val) for k, val in outs.items()}
return cp.asnumpy(v), cp.asnumpy(packed), cp.asnumpy(cell), oCuda Maths — Solar Billion
A Python command-line tool in GPU Drivers for Global Grid.
othergpu-drivers-for-global-grid / cuda-maths/solar-billion/main.py · lines 1–6 of 6 · Entry point
- What it does
- Uses libraries multiprocessing, run_all.
- Why it exists in the grid workflow
- Domain stage sub33kv_design (path word 'solar'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary. README: "Files: `solar-billion/` — `cpu_ref.py` (scalar reference), `cpu_vec.py` (vectorised, multiprocess), `gpu_vec.py` (CuPy), `main.py`, plus `FORMULA.txt` and `RESULTS.txt` with the full verdict counts."
- Downstream impact
- It is itself an entry point (Python CLI); no other file was found loading it.
- What it achieves
- The entry point. The guard is required on Windows: the worker processes re-import the main module, and without it they would re-run the whole job.
- Why it matters
- No other file in the estate was found to import it; it is an entry point.
- Application
- gpu-drivers-for-global-grid · cuda-maths/solar-billion · Python CLI
- Uses
- multiprocessing, run_all
- 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
- gpu-drivers-for-global-grid@6c47912a8dde251ffebd92ff129e6a0c11c4ebfe cuda-maths/solar-billion/main.py:1-6 · blob 958c50eb26fa77d9a758fc6c3d4e47916b473d3e · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: unknown · effects: none found · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: unknown
# main.py - the entry point. The guard is required on Windows: the worker processes
# re-import the main module, and without it they would re-run the whole job.
if __name__ == "__main__":
import multiprocessing
multiprocessing.freeze_support()
import run_all # noqa: F401 (running the module IS the job)Orient16 Responsive Panel
A JavaScript file in the atlas folder of GridAtlas.
rendergridatlas / atlas/modules/202612031346-orient16-responsive-panel.js · lines 1–90 of 90 · version 2026-12-03 13:46 · Not reached from any entry point (candidate for review)
- What it does
- It draws its content. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage sub33kv_design (path word 'panel'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary.
- Inputs & outputs
- In: user-supplied file (file picker).
- What it achieves
- Native controls and route state stay owned by their existing modules.
- Why it matters
- No other file in the estate was found to import it.
- Application
- gridatlas · atlas/modules · script
- Uses
- none found
- 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
- gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 atlas/modules/202612031346-orient16-responsive-panel.js:1-90 · blob a1498d9fcdb5d4da8d2d9ff065fc8edd7da0fef9 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: unreached_review
/* V9.203: presentation-only SatNav cartridge. Native controls and route state stay owned by their existing modules. */
void function () {
if (document.getElementById('g203-satnav-panel-style')) return;
const style = document.createElement('style');
style.id = 'g203-satnav-panel-style';
style.textContent = `
html #satnav-compact {
--g203-panel-width: min(208px, calc(100vw - 16px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
--g203-panel-top: max(8px, env(safe-area-inset-top, 0px), var(--gridatlas-menu-bar-clear, 8px), var(--satnav-measured-menu-bottom, 8px));
--g203-panel-reserve: calc(var(--g203-dock-clearance, 64px) + var(--g203-access-reserve, 48px) + env(safe-area-inset-bottom, 0px));
left: max(8px, env(safe-area-inset-left, 0px)) !important;
right: auto !important;
top: var(--g203-panel-top) !important;
bottom: auto !important;
width: var(--g203-panel-width) !important;
box-sizing: border-box;
max-height: max(44px, calc(100dvh - var(--g203-panel-top) - var(--g203-panel-reserve))) !important;
overflow-x: hidden;
overflow-y: auto;
gap: 3px;
font: 12px/1.25 system-ui, sans-serif;
}
html:has(#satnav-access[open]:not([hidden])) #satnav-compact {
--g203-access-reserve: calc(40dvh + 4px);
}
html #satnav-compact[hidden] { display: none !important; }
html #satnav-compact button,
html #satnav-compact select,
html #satnav-compact summary {
box-sizing: border-box;
min-width: 0;
max-width: 100%;
min-height: 44px;
padding: 4px 5px;
font: inherit;
overflow-wrap: anywhere;
}
html #satnav-compact summary { cursor: pointer; }
html #satnav-compact .satnav-row { gap: 3px; }
html #satnav-compact .satnav-row button { flex: 1 1 0; }
html #satnav-compact .satnav-endpoint b { width: 38px; }
html #satnav-compact #satnav-walk-actions { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 3px; }
html #satnav-compact #satnav-walk-actions select { grid-column: 1 / -1; }
html #satnav-compact #satnav-field-tools { display: grid; gap: 3px; min-width: 0; }
html #satnav-compact #satnav-field-tools > * { min-width: 0; max-width: 100%; }
html #satnav-compact details { background: #081820ed; border-radius: 4px; overflow-wrap: anywhere; }
html #satnav-compact details summary { padding-inline: 6px; }
html #satnav-compact input:not([type=file]) { min-width: 0; max-width: 100%; box-sizing: border-box; }
html #satnav-compact .satnav-readout, html #satnav-compact #satnav-walk-guidance { padding: 3px 5px; font-size: 11px; }
html #satnav-access {
left: max(8px, env(safe-area-inset-left, 0px)) !important;
right: auto !important;
bottom: calc(var(--g203-dock-clearance, 64px) + env(safe-area-inset-bottom, 0px)) !important;
width: min(208px, calc(100vw - 16px));
max-width: calc(100vw - 16px);
box-sizing: border-box;
max-height: 40dvh;
overflow-y: auto;
}
html #satnav-access summary { min-height: 44px; display: flex; align-items: center; }
@media (orientation: landscape) and (max-height: 500px) {
html #satnav-compact { --g203-panel-width: min(190px, calc(100vw - 16px)); }
}
/* ORIENT-16: presentation only; no camera, GPS, or route state changes. */
@media (orientation: landscape) and (max-height: 500px) and (min-width: 600px) {
html #satnav-compact { --g203-panel-width: min(172px, calc(100vw - 16px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px))); }
}
@media (min-width: 1600px) and (min-height: 700px) {
html #satnav-compact { --g203-panel-width: min(288px, calc(100vw - 16px)); font-size: 13px; }
html #satnav-compact #satnav-walk-guidance { font-size: 13px; }
}
html #satnav-walk-actions:has(option[value="walking"]:checked) #satnav-walk-mode {
border-color: #8bf7f7; animation: orient16-walking 240ms ease-out 1;
}
html #satnav-walk-actions:has(option[value="driving"]:checked) #satnav-walk-mode {
border-color: #ffcf80; animation: orient16-driving 140ms ease-out 1;
}
html #satnav-walk-actions:has(option[value="direct"]:checked) #satnav-walk-mode {
border-color: #b2faf7; animation: orient16-manual 180ms ease-out 1;
}
@keyframes orient16-walking { from { box-shadow: inset 0 0 0 2px #8bf7f7; } to { box-shadow: none; } }
@keyframes orient16-driving { from { box-shadow: inset 0 0 0 2px #ffcf80; } to { box-shadow: none; } }
@keyframes orient16-manual { from { box-shadow: inset 0 0 0 2px #b2faf7; } to { box-shadow: none; } }
@media (prefers-reduced-motion: reduce) {
html #satnav-walk-actions:has(option:checked) #satnav-walk-mode { animation: none !important; }
}
`;
document.head.append(style);
}();