minjiechen commited on
Commit
2f04bef
·
verified ·
1 Parent(s): fb4c97d

Publish ThinkPower topology analysis website

Browse files

Independent static website with browser-based analysis and optional direct vision inference. Links to the restored original XFLY simulation Space.

Files changed (7) hide show
  1. README.md +8 -1
  2. models.py +3 -1
  3. static/app.js +36 -20
  4. static/engine.js +1 -1
  5. static/index.html +2 -2
  6. static/style.css +2 -0
  7. test_per_unit.py +12 -0
README.md CHANGED
@@ -11,7 +11,8 @@ pinned: false
11
  # ThinkPower
12
 
13
  The main view pairs each selected converter schematic with an averaged DC
14
- transformer and a single output-referred effective resistance. The transformer
 
15
  label gives the nominal voltage conversion ratio; it does not imply physical
16
  isolation. Normalized weights, the resistance sweep and model details are
17
  collapsed to keep the comparison simple. Upload review is available in a dialog.
@@ -81,6 +82,12 @@ includes selected schematic assets, not the full manuscript.
81
  `Rout_est = RIND + hypot(RFET + RCAP, RSSL)`.
82
 
83
  FSL and SSL represent limits of the same charging process. They are not summed.
 
 
 
 
 
 
84
  The reference model assumes two matched flat winding currents, a common 12 A0
85
  transistor-area budget, fixed 4:1 allocations, identical device technology, zero
86
  clamp ESR, and equal main/clamp capacitance in 2SBUCK. Switching, gate-drive,
 
11
  # ThinkPower
12
 
13
  The main view pairs each selected converter schematic with an averaged DC
14
+ transformer and coefficient-weighted switch, capacitor-ESR and winding resistances
15
+ grouped as RFSL, plus a separate charging-loss contribution. The transformer
16
  label gives the nominal voltage conversion ratio; it does not imply physical
17
  isolation. Normalized weights, the resistance sweep and model details are
18
  collapsed to keep the comparison simple. Upload review is available in a dialog.
 
82
  `Rout_est = RIND + hypot(RFET + RCAP, RSSL)`.
83
 
84
  FSL and SSL represent limits of the same charging process. They are not summed.
85
+ The series charging-loss increment is
86
+ `RSSL,add = hypot(RFET + RCAP, RSSL) - (RFET + RCAP)`, so
87
+ `Req = RFSL + RSSL,add`. The orange inset retains the raw RSSL asymptote.
88
+ A parallel input resistor represents switching loss with `Rsw,in = Vin^2/Psw`.
89
+ It is symbolic until operating-point switching-loss data are supplied and does
90
+ not change the numerical Req comparison. SVG and CSV exports preserve this scope.
91
  The reference model assumes two matched flat winding currents, a common 12 A0
92
  transistor-area budget, fixed 4:1 allocations, identical device technology, zero
93
  clamp ESR, and equal main/clamp capacitance in 2SBUCK. Switching, gate-drive,
models.py CHANGED
@@ -148,7 +148,9 @@ def analyze_pu(payload):
148
  if not valid(key,m):return None
149
  a,b,c=coefficients(key,2*m)
150
  fet=a;cap=b*rho_c;ind=.5*rho_l;ssl=c*rho_q
151
- return dict(fet=fet,cap=cap,ind=ind,ssl=ssl,fsl=fet+cap+ind,total=ind+math.hypot(fet+cap,ssl),coefficients=[a,b,.5,c],D=2*m)
 
 
152
  rows=[]
153
  for key in dict.fromkeys(selected):
154
  r=result(key,M);meta=INDEX[key]
 
148
  if not valid(key,m):return None
149
  a,b,c=coefficients(key,2*m)
150
  fet=a;cap=b*rho_c;ind=.5*rho_l;ssl=c*rho_q
151
+ net=fet+cap
152
+ increment=ssl*ssl/(math.hypot(net,ssl)+net) if net or ssl else 0
153
+ return dict(fet=fet,cap=cap,ind=ind,ssl=ssl,ssl_series=increment,fsl=fet+cap+ind,total=ind+math.hypot(net,ssl),coefficients=[a,b,.5,c],D=2*m)
154
  rows=[]
155
  for key in dict.fromkeys(selected):
156
  r=result(key,M);meta=INDEX[key]
static/app.js CHANGED
@@ -9,28 +9,44 @@ function download(name,body,type='image/svg+xml'){const u=URL.createObjectURL(ne
9
  function params(){return {ratio,topologies:[...selected],...Object.fromEntries(['rho_c','rho_l','rho_q'].map(k=>[k,Number($('#'+k).value)]))}}
10
  function equivalent(r){
11
  const boost=r.id==='boost',unknown=r.id==='ns',ratioText=unknown?'1 : M':boost?`1 : ${ratio}`:`${ratio} : 1`,M=unknown?null:boost?ratio:1/ratio;
12
- const ratioNote=unknown?'Conversion ratio requires a state model':boost&&ratio<4?'Target ratio · requires low-duty analysis':!r.valid&&!boost?'Target ratio · outside supported model range':'Ideal averaged DC conversion';
13
- const value=r.valid?fmt(r.total)+' Rₛ':'not derived',wire='#455c50',accent=r.valid?'#157e70':'#9eac9e';
14
- return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 660 255" role="img" aria-label="${esc(r.short)} averaged equivalent circuit: ideal DC transformer ${ratioText}, followed by ${r.valid?'output resistance '+value:'an undetermined output resistance'}"><title>${esc(r.short)}: ideal DC transformer plus output-referred effective resistance</title>
15
- <rect width="660" height="255" fill="white"/>
16
- <g fill="none" stroke="${wire}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
17
- <path d="M55 91H180M180 187V221M55 221H599M235 187V221M235 91H315M425 91H599"/>
18
- <path d="M180 91c18 0 18 24 0 24c18 0 18 24 0 24c18 0 18 24 0 24c18 0 18 24 0 24"/>
19
- <path d="M235 91c-18 0 -18 24 0 24c-18 0 -18 24 0 24c-18 0 -18 24 0 24c-18 0 -18 24 0 24"/>
20
- <path d="M204 87V191M211 87V191" stroke="#90a394" stroke-width="1.5"/>
21
- <rect x="315" y="77" width="110" height="28" rx="1" fill="${r.valid?'#eff6f0':'#f5f6f4'}" stroke="${accent}" ${r.valid?'':'stroke-dasharray="5 4"'}/>
22
- <circle cx="55" cy="91" r="4" fill="white"/><circle cx="55" cy="221" r="4" fill="white"/><circle cx="599" cy="91" r="4" fill="white"/><circle cx="599" cy="221" r="4" fill="white"/>
23
- <path d="M476 63H531" stroke="#708b78" stroke-width="1.5"/><path d="M531 63l-7 -4v8z" fill="#708b78" stroke="none"/>
 
 
 
 
 
 
 
 
24
  </g>
25
- <g fill="${wire}" font-family="Arial,Helvetica,sans-serif" text-anchor="middle"><text x="207" y="39" font-size="20" fill="#157e70">${ratioText}</text><text x="207" y="57" font-size="9" fill="#8a9e8c">${ratioNote}</text>
26
- <text x="70" y="70" font-size="14">V<tspan baseline-shift="sub" font-size="10">in</tspan></text><text x="591" y="70" font-size="14">V<tspan baseline-shift="sub" font-size="10">out</tspan></text><text x="503" y="51" font-size="12">I<tspan baseline-shift="sub" font-size="9">out</tspan></text>
27
- <text x="370" y="64" font-size="14">R<tspan baseline-shift="sub" font-size="10">eq</tspan></text><text x="370" y="131" font-size="17" fill="${accent}">${value}</text>
28
- <text x="371" y="150" font-size="10" fill="#8a9e8c">${r.valid?'output-referred effective resistance':'requires a verified loss model'}</text>
29
- <text x="476" y="191" font-size="13" fill="#6e8874">${M!==null?`M = ${fmt(M)} · Vout ≈ M Vin − Iout Req`:'Vout ≈ M Vin − Iout Req'}</text>
30
- <text x="337" y="248" font-size="9" fill="#95a496">Common reference · averaged model, not a physical isolation transformer</text></g></svg>`;
 
 
 
 
 
 
 
 
31
  }
32
  function cards(){
33
- $('#circuits').innerHTML=report.rows.map(r=>{const meta=catalog.find(c=>c.id===r.id),sub=r.id==='xfly2p'?'Six-switch cell · two-command reference':r.id==='xfly4p'?'Split-middle cell · four-pulse reference':meta.family;return `<article class="circuit-card" data-topology="${r.id}"><div class="topology"><h2>${esc(meta.name)}</h2><div class="sub">${esc(sub)}</div><img src="./assets/${meta.asset}" alt="${esc(meta.name)} topology"></div><div class="equivalent"><div class="eq-heading"><span>IDEAL CONVERSION + EFFECTIVE RESISTANCE</span><span class="eq-value ${r.valid?'':'unsupported'}">${r.valid?'Req / RS = '+fmt(r.total):'No numerical loss model'}</span></div><div class="equivalent-drawing">${equivalent(r)}</div><div class="eq-caption"><p>${r.valid?`RFSL / RS = ${fmt(r.fsl)} · RSSL / RS = ${fmt(r.ssl)}${r.ssl>0?' · combined by interpolation':''}`:esc(r.domain)}</p><button data-svg="${r.id}">↓ SVG</button></div>${r.valid?`<div class="components">${['RFET','RCAP','RIND','RSSL'].map((n,i)=>`<span>${n}/RS <b>${fmt(r[['fet','cap','ind','ssl'][i]])}</b></span>`).join('')}</div>`:''}</div></article>`}).join('');
34
  $$('[data-svg]').forEach(b=>b.onclick=()=>download('thinkpower-'+b.dataset.svg+'-equivalent.svg',$(`[data-topology="${b.dataset.svg}"] svg`).outerHTML));
35
  $('#coefficients').innerHTML=report.rows.map(r=>`<div class="formula"><b>${esc(r.short)}</b> · ${esc(r.domain)}${(r.formulas||['Not derived for this topology.']).map((f,i)=>`<code>${['RFET','RCAP','RIND','RSSL'][i]} = ${esc(f)}</code>`).join('')}<p>${esc(r.note)}</p></div>`).join('');
36
  }
@@ -60,7 +76,7 @@ function drawSweep(){if(!report)return;chart('rout-chart',report.curves,{xlabel:
60
  $('#sweep-section').addEventListener('toggle',()=>{if($('#sweep-section').open)drawSweep()});
61
  $$('[data-ratio]').forEach(b=>b.onclick=()=>{ratio=Number(b.dataset.ratio);$$('[data-ratio]').forEach(v=>v.classList.toggle('active',v===b));update()});
62
  $('#apply-weights').onclick=update;$('#reset').onclick=()=>{for(const [k,v] of Object.entries({rho_c:1,rho_l:1,rho_q:20}))$('#'+k).value=v;$('#toast').hidden=true;clearTimeout(timer);update()};
63
- $('#export-csv').onclick=()=>{if(!report)return;const rows=[['Topology','Target_ratio','kFET_Rs','kCAP_Rc','kIND_Rl','kSSL_over_Cf_fs','RFET_pu','RCAP_pu','RIND_pu','RSSL_pu','Req_pu','RFSL_pu','rho_C','rho_L','rho_Q','Model_domain'],...report.rows.map(r=>[r.short,ratio,...(r.valid?r.coefficients:['','','','']),...['fet','cap','ind','ssl','total','fsl'].map(k=>r.valid?r[k]:''),report.normalization.rho_c,report.normalization.rho_l,report.normalization.rho_q,r.domain])];download('thinkpower-per-unit-comparison.csv',rows.map(r=>r.map(v=>'"'+String(v).replaceAll('"','""')+'"').join(',')).join('\n'),'text/csv')};
64
  $('#open-upload').onclick=()=>$('#upload-dialog').showModal();$('#close-upload').onclick=()=>$('#upload-dialog').close();
65
  async function loadImage(file){if(!file)return;if(!['image/png','image/jpeg','image/webp'].includes(file.type)||file.size>8000000){toast('Choose a PNG, JPEG or WebP smaller than 8 MB.');return}imageData=await new Promise((resolve,reject)=>{const r=new FileReader();r.onload=()=>resolve(r.result);r.onerror=reject;r.readAsDataURL(file)});$('#image-preview').src=imageData;$('#image-preview').hidden=false;$('#inspect').disabled=false;$('#upload-status').textContent=file.name+' · ready for interpretation';$('#interpretation').hidden=true}
66
  $('#image-upload').onchange=e=>loadImage(e.target.files[0]);$('#dropzone').ondragover=e=>{e.preventDefault();$('#dropzone').classList.add('drag')};$('#dropzone').ondragleave=()=>$('#dropzone').classList.remove('drag');$('#dropzone').ondrop=e=>{e.preventDefault();$('#dropzone').classList.remove('drag');loadImage(e.dataTransfer.files[0])};
 
9
  function params(){return {ratio,topologies:[...selected],...Object.fromEntries(['rho_c','rho_l','rho_q'].map(k=>[k,Number($('#'+k).value)]))}}
10
  function equivalent(r){
11
  const boost=r.id==='boost',unknown=r.id==='ns',ratioText=unknown?'1 : M':boost?`1 : ${ratio}`:`${ratio} : 1`,M=unknown?null:boost?ratio:1/ratio;
12
+ const ratioNote=unknown?'State model required':boost&&ratio<4?'Target · low-duty analysis required':!r.valid&&!boost?'Target · outside supported range':'Ideal averaged DC conversion';
13
+ const ink='#455c50',teal='#157e70',orange='#bb7d37',blue='#62869d',neutral='#a0aaa0',coeff=v=>Number(v.toPrecision(4)),value=(v)=>r.valid?fmt(v)+' Rₛ':'not derived';
14
+ const blocks=[{x:358,label:'R<tspan baseline-shift="sub" font-size="12">S</tspan>',title:'R_FET: transistor conduction contribution',text:r.valid?coeff(r.coefficients[0])+' Rₛ':'unknown'},
15
+ {x:466,label:'R<tspan baseline-shift="sub" font-size="12">C</tspan>',title:'R_CAP: capacitor ESR contribution',text:r.valid?coeff(r.coefficients[1])+' R꜀':'unknown'},
16
+ {x:574,label:'R<tspan baseline-shift="sub" font-size="12">L</tspan>',title:'R_IND: winding conduction contribution',text:r.valid?coeff(r.coefficients[2])+' Rₗ':'unknown'}];
17
+ const resistorMarkup=blocks.map(b=>`<g data-loss="${b.title.split(':')[0]}"><title>${b.title}</title><rect x="${b.x}" y="96" width="85" height="29" rx="1" fill="#eef5ef" stroke="${r.valid?teal:neutral}" stroke-width="2"/><text x="${b.x+42.5}" y="84" font-size="18">${b.label}</text><text x="${b.x+42.5}" y="147" font-size="15" fill="${teal}">${b.text}</text></g>`).join('');
18
+ return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 940 350" role="img" aria-label="${esc(r.short)}: ideal DC transformer ${ratioText}, three conduction resistances grouped as RFSL, an incremental SSL series resistance, and a parallel input switching-loss resistance"><title>${esc(r.short)}: FSL, SSL and switching-loss equivalent circuit</title>
19
+ <rect width="940" height="350" fill="white"/>
20
+ <g fill="none" stroke="${ink}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
21
+ <path d="M35 110H225M225 230V274M35 274H897M300 230V274M300 110H358M443 110H466M551 110H574M659 110H714M805 110H897"/>
22
+ <path d="M225 110c20 0 20 30 0 30c20 0 20 30 0 30c20 0 20 30 0 30c20 0 20 30 0 30"/>
23
+ <path d="M300 110c-20 0 -20 30 0 30c-20 0 -20 30 0 30c-20 0 -20 30 0 30c-20 0 -20 30 0 30"/>
24
+ <path d="M260 106V234M267 106V234" stroke="#90a394" stroke-width="1.5"/>
25
+ <path d="M112 110V160M112 215V274" stroke="${blue}"/>
26
+ <rect data-loss="R_SW_IN" x="99" y="160" width="26" height="55" fill="#f1f5f8" stroke="${blue}" stroke-dasharray="5 3"/>
27
+ <path d="M358 160V169H659V160" stroke="${teal}" stroke-width="1.4"/>
28
+ <rect data-loss="R_SSL_SERIES" x="714" y="96" width="91" height="29" rx="1" fill="#faf2e6" stroke="${orange}" ${r.valid?'':'stroke-dasharray="5 3"'}/>
29
+ <circle cx="112" cy="110" r="3" fill="${ink}"/><circle cx="112" cy="274" r="3" fill="${ink}"/>
30
+ <circle cx="35" cy="110" r="4" fill="white"/><circle cx="35" cy="274" r="4" fill="white"/><circle cx="897" cy="110" r="4" fill="white"/><circle cx="897" cy="274" r="4" fill="white"/>
31
+ <path d="M833 75H882" stroke="#708b78" stroke-width="1.5"/><path d="M882 75l-7 -4v8z" fill="#708b78" stroke="none"/>
32
  </g>
33
+ <g fill="${ink}" font-family="Arial,Helvetica,sans-serif" text-anchor="middle">
34
+ ${resistorMarkup}
35
+ <text x="263" y="43" font-size="23" fill="${teal}">${ratioText}</text><text x="263" y="64" font-size="11" fill="#8a9e8c">${ratioNote}</text>
36
+ <text x="49" y="87" font-size="18">V<tspan baseline-shift="sub" font-size="12">in</tspan></text><text x="890" y="87" font-size="18">V<tspan baseline-shift="sub" font-size="12">out</tspan></text><text x="857" y="61" font-size="16">I<tspan baseline-shift="sub" font-size="11">out</tspan></text>
37
+ <text x="154" y="170" font-size="16" fill="${blue}" text-anchor="start">R<tspan baseline-shift="sub" font-size="11">SW,in</tspan></text><text x="153" y="191" font-size="11" fill="${blue}" text-anchor="start">switching</text><text x="153" y="207" font-size="11" fill="${blue}" text-anchor="start">loss</text>
38
+ <text x="112" y="245" font-size="11" fill="${blue}">not quantified</text>
39
+ <text x="509" y="194" font-size="18" fill="${teal}">R<tspan baseline-shift="sub" font-size="12">FSL</tspan> = ${value(r.fsl)}</text>
40
+ <text x="759" y="84" font-size="17" fill="${orange}">R<tspan baseline-shift="sub" font-size="11">SSL,add</tspan></text><text x="759" y="147" font-size="15" fill="${orange}">${value(r.ssl_series)}</text>
41
+ <rect x="684" y="171" width="190" height="64" rx="5" fill="#fcf7ee" stroke="#e6d5b8"/>
42
+ <text x="779" y="195" font-size="16" fill="${orange}">R<tspan baseline-shift="sub" font-size="11">SSL</tspan> = ${value(r.ssl)}</text><text x="779" y="218" font-size="11" fill="${orange}">estimated charge-sharing limit</text>
43
+ <text x="490" y="239" font-size="14" fill="#6e8874">${M!==null?`M = ${fmt(M)} · Req / Rs = ${r.valid?fmt(r.total):'unknown'}`:'M and Req require a state model'}</text>
44
+ <text x="187" y="309" font-size="13" fill="${blue}">Rsw,in = Vin² / Psw · input-referred</text>
45
+ <text x="647" y="309" font-size="12" fill="#8a9e8c">Req = RFSL + RSSL,add · charging limit is not added twice</text>
46
+ <text x="470" y="339" font-size="11" fill="#95a496">Averaged loss model · switching branch needs separate device/operating-point loss data</text></g></svg>`;
47
  }
48
  function cards(){
49
+ $('#circuits').innerHTML=report.rows.map(r=>{const meta=catalog.find(c=>c.id===r.id),sub=r.id==='xfly2p'?'Six-switch cell · two-command reference':r.id==='xfly4p'?'Split-middle cell · four-pulse reference':meta.family;return `<article class="circuit-card" data-topology="${r.id}"><div class="topology"><h2>${esc(meta.name)}</h2><div class="sub">${esc(sub)}</div><img src="./assets/${meta.asset}" alt="${esc(meta.name)} topology"></div><div class="equivalent"><div class="eq-heading"><span>IDEAL CONVERSION + LOSS MODEL</span><span class="eq-value ${r.valid?'':'unsupported'}">${r.valid?'Req / RS = '+fmt(r.total):'No numerical loss model'}</span></div><div class="equivalent-drawing">${equivalent(r)}</div><span class="scroll-note">Swipe to view the full loss circuit →</span><div class="eq-caption"><p>${r.valid?`RFSL / RS = ${fmt(r.fsl)} · RSSL,add / RS = ${fmt(r.ssl_series)} · RSW,in not quantified`:esc(r.domain)}</p><button data-svg="${r.id}">↓ SVG</button></div>${r.valid?`<div class="components">${['RFET','RCAP','RIND','RSSL'].map((n,i)=>`<span>${n}/RS <b>${fmt(r[['fet','cap','ind','ssl'][i]])}</b></span>`).join('')}</div>`:''}</div></article>`}).join('');
50
  $$('[data-svg]').forEach(b=>b.onclick=()=>download('thinkpower-'+b.dataset.svg+'-equivalent.svg',$(`[data-topology="${b.dataset.svg}"] svg`).outerHTML));
51
  $('#coefficients').innerHTML=report.rows.map(r=>`<div class="formula"><b>${esc(r.short)}</b> · ${esc(r.domain)}${(r.formulas||['Not derived for this topology.']).map((f,i)=>`<code>${['RFET','RCAP','RIND','RSSL'][i]} = ${esc(f)}</code>`).join('')}<p>${esc(r.note)}</p></div>`).join('');
52
  }
 
76
  $('#sweep-section').addEventListener('toggle',()=>{if($('#sweep-section').open)drawSweep()});
77
  $$('[data-ratio]').forEach(b=>b.onclick=()=>{ratio=Number(b.dataset.ratio);$$('[data-ratio]').forEach(v=>v.classList.toggle('active',v===b));update()});
78
  $('#apply-weights').onclick=update;$('#reset').onclick=()=>{for(const [k,v] of Object.entries({rho_c:1,rho_l:1,rho_q:20}))$('#'+k).value=v;$('#toast').hidden=true;clearTimeout(timer);update()};
79
+ $('#export-csv').onclick=()=>{if(!report)return;const rows=[['Topology','Target_ratio','kFET_Rs','kCAP_Rc','kIND_Rl','kSSL_over_Cf_fs','RFET_pu','RCAP_pu','RIND_pu','RSSL_pu','Req_pu','RFSL_pu','RSSL_add_pu','Rsw_in_status','rho_C','rho_L','rho_Q','Model_domain'],...report.rows.map(r=>[r.short,ratio,...(r.valid?r.coefficients:['','','','']),...['fet','cap','ind','ssl','total','fsl','ssl_series'].map(k=>r.valid?r[k]:''),'not quantified',report.normalization.rho_c,report.normalization.rho_l,report.normalization.rho_q,r.domain])];download('thinkpower-per-unit-comparison.csv',rows.map(r=>r.map(v=>'"'+String(v).replaceAll('"','""')+'"').join(',')).join('\n'),'text/csv')};
80
  $('#open-upload').onclick=()=>$('#upload-dialog').showModal();$('#close-upload').onclick=()=>$('#upload-dialog').close();
81
  async function loadImage(file){if(!file)return;if(!['image/png','image/jpeg','image/webp'].includes(file.type)||file.size>8000000){toast('Choose a PNG, JPEG or WebP smaller than 8 MB.');return}imageData=await new Promise((resolve,reject)=>{const r=new FileReader();r.onload=()=>resolve(r.result);r.onerror=reject;r.readAsDataURL(file)});$('#image-preview').src=imageData;$('#image-preview').hidden=false;$('#inspect').disabled=false;$('#upload-status').textContent=file.name+' · ready for interpretation';$('#interpretation').hidden=true}
82
  $('#image-upload').onchange=e=>loadImage(e.target.files[0]);$('#dropzone').ondragover=e=>{e.preventDefault();$('#dropzone').classList.add('drag')};$('#dropzone').ondragleave=()=>$('#dropzone').classList.remove('drag');$('#dropzone').ondrop=e=>{e.preventDefault();$('#dropzone').classList.remove('drag');loadImage(e.dataTransfer.files[0])};
static/engine.js CHANGED
@@ -19,7 +19,7 @@ async function inspect(p,data){if(typeof p.image!=='string'||!/^data:image\/(png
19
  function analyzePU(payload,data){
20
  const rho_c=num(payload,'rho_c',1,0,1e6),rho_l=num(payload,'rho_l',1,0,1e6),rho_q=num(payload,'rho_q',20,0,1e9),ratio=num(payload,'ratio',4,1.01,256),M=1/ratio,index=Object.fromEntries(data.catalog.map(c=>[c.id,c]));
21
  let selected=payload.topologies??['xfly2p','xfly4p','3lbuck','2sbuck','buck'];if(!Array.isArray(selected)||!selected.length||selected.some(k=>!index[k]))throw Error('Select known topologies');selected=[...new Set(selected)];
22
- const result=(k,m)=>{if(!valid(k,m))return null;const [a,b,c]=coefficients(k,2*m),fet=a,cap=b*rho_c,ind=.5*rho_l,ssl=c*rho_q;return {fet,cap,ind,ssl,fsl:fet+cap+ind,total:ind+Math.hypot(fet+cap,ssl),coefficients:[a,b,.5,c],D:2*m}};
23
  const rows=selected.map(id=>{const r=result(id,M),meta=index[id];return {id,name:meta.name,short:meta.short,color:meta.color,note:meta.note,formulas:data.formulas[id],allocation:data.formulas[id]?allocation(id,index):null,valid:!!r,domain:meta.range,...(r||{})}});
24
  const xs=[...new Set([...linspace(.0005,.4995,500),.25,.5,M])].sort((a,b)=>a-b),curves=selected.map(id=>({id,name:index[id].short,color:index[id].color,points:xs.flatMap(m=>{const r=result(id,m);return r?[[m,r.total]]:[]})})).filter(s=>s.points.length);
25
  return {ratio,M,normalization:{base:'R_S',rho_c,rho_l,rho_q,component_unit:'R/R_S',coefficient_bases:['R_S','R_C','R_L','1/(C_F f_s)']},rows,curves,provenance:'XFLY-IEEE Section V-F, Table I; Figures 18–20. Dimensionless form of the current manuscript models.',assumptions:[
 
19
  function analyzePU(payload,data){
20
  const rho_c=num(payload,'rho_c',1,0,1e6),rho_l=num(payload,'rho_l',1,0,1e6),rho_q=num(payload,'rho_q',20,0,1e9),ratio=num(payload,'ratio',4,1.01,256),M=1/ratio,index=Object.fromEntries(data.catalog.map(c=>[c.id,c]));
21
  let selected=payload.topologies??['xfly2p','xfly4p','3lbuck','2sbuck','buck'];if(!Array.isArray(selected)||!selected.length||selected.some(k=>!index[k]))throw Error('Select known topologies');selected=[...new Set(selected)];
22
+ const result=(k,m)=>{if(!valid(k,m))return null;const [a,b,c]=coefficients(k,2*m),fet=a,cap=b*rho_c,ind=.5*rho_l,ssl=c*rho_q;const net=fet+cap,ssl_series=(net||ssl)?ssl*ssl/(Math.hypot(net,ssl)+net):0;return {fet,cap,ind,ssl,ssl_series,fsl:fet+cap+ind,total:ind+Math.hypot(net,ssl),coefficients:[a,b,.5,c],D:2*m}};
23
  const rows=selected.map(id=>{const r=result(id,M),meta=index[id];return {id,name:meta.name,short:meta.short,color:meta.color,note:meta.note,formulas:data.formulas[id],allocation:data.formulas[id]?allocation(id,index):null,valid:!!r,domain:meta.range,...(r||{})}});
24
  const xs=[...new Set([...linspace(.0005,.4995,500),.25,.5,M])].sort((a,b)=>a-b),curves=selected.map(id=>({id,name:index[id].short,color:index[id].color,points:xs.flatMap(m=>{const r=result(id,m);return r?[[m,r.total]]:[]})})).filter(s=>s.points.length);
25
  return {ratio,M,normalization:{base:'R_S',rho_c,rho_l,rho_q,component_unit:'R/R_S',coefficient_bases:['R_S','R_C','R_L','1/(C_F f_s)']},rows,curves,provenance:'XFLY-IEEE Section V-F, Table I; Figures 18–20. Dimensionless form of the current manuscript models.',assumptions:[
static/index.html CHANGED
@@ -1,12 +1,12 @@
1
  <!doctype html>
2
  <html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="description" content="Power converter topologies and their ideal conversion ratio plus effective output resistance."><title>ThinkPower — Topology & Equivalent Circuit</title><link rel="stylesheet" href="./style.css"></head><body>
3
  <header><a class="brand" href="./index.html"><span>╳</span>ThinkPower</a><div>Topology → equivalent circuit</div><a href="https://huggingface.co/spaces/minjiechen/XFLY" target="_blank" rel="noopener">NGSpice ↗</a></header>
4
- <main><div class="intro"><div><h1>A topology. Its equivalent circuit.</h1><p>Ideal voltage conversion, followed by the output-referred effective resistance. All resistance values are per unit of R<sub>S</sub>.</p></div><button id="open-upload">+ Upload topology</button></div>
5
  <section class="toolbar" aria-label="Comparison settings"><div class="ratio-control"><label>Conversion ratio</label><div id="ratios"><button data-ratio="2">2:1</button><button data-ratio="4" class="active">4:1</button><button data-ratio="6">6:1</button><button data-ratio="8">8:1</button><button data-ratio="16">16:1</button></div></div><details class="weights"><summary>Per-unit loss weights</summary><div><label>R<sub>C</sub> / R<sub>S</sub><input id="rho_c" type="number" value="1" min="0" step="0.1"></label><label>R<sub>L</sub> / R<sub>S</sub><input id="rho_l" type="number" value="1" min="0" step="0.1"></label><label>1 / (C<sub>F</sub> f<sub>s</sub> R<sub>S</sub>)<input id="rho_q" type="number" value="20" min="0" step="1"></label><button id="apply-weights">Apply</button><button id="reset">Reset</button></div></details><button id="export-csv" class="plain">↓ CSV</button></section>
6
  <div id="topology-picker" class="picker" aria-label="Topologies to compare"></div><div id="status" role="status" class="status">Loading topology models…</div>
7
  <div class="column-labels"><span>CONVERTER TOPOLOGY</span><span>AVERAGED DC EQUIVALENT CIRCUIT</span></div><section id="circuits" aria-label="Topology and equivalent circuit comparison"></section>
8
  <details id="sweep-section" class="secondary-panel"><summary>Effective resistance versus conversion ratio</summary><div id="legend"></div><div id="rout-chart" class="chart"></div><p>The horizontal axis is the step-down ratio M = Vout/Vin. Only supported duty ranges are plotted.</p></details>
9
- <details class="secondary-panel" id="model-details"><summary>How the effective resistance is calculated</summary><p>The ideal DC transformer represents the <em>averaged conversion ratio</em>; it does not imply a physical transformer or galvanic isolation. The series resistor is referred to the output.</p><div class="equation">V<sub>out</sub> ≈ M V<sub>in</sub> − I<sub>out</sub> R<sub>eq</sub></div><div class="equation">R<sub>eq</sub> = R<sub>IND</sub> + √[(R<sub>FET</sub> + R<sub>CAP</sub>)² + R<sub>SSL</sub>²]</div><p>FSL and SSL are limits of the same charging process; they are combined by the paper’s interpolation, rather than added as independent series resistors. All displayed numbers divide resistance by R<sub>S</sub>. Device allocations are fixed at the 4:1 design point with total area 12 A₀.</p><p>Assumptions: two matched flat phase currents, identical device technology, and zero clamp-capacitor ESR. Switching transitions, gate drive, magnetic core loss, winding ripple, and dead time are excluded. XFLY2P uses the paper’s effective six-switch model with the physical split-middle area normalization. XFLY4P applies only to the specified four-pulse realization. Unsupported operating points receive no numerical resistance.</p><div id="coefficients"></div></details>
10
  <footer><span>ThinkPower · Based on the XFLY family analysis</span><span>Per-unit analytical model · verify with switched simulation</span></footer></main>
11
  <dialog id="upload-dialog"><div class="dialog-heading"><h2>Upload a topology</h2><button id="close-upload" aria-label="Close upload">×</button></div><label class="dropzone" id="dropzone">Choose or drop a schematic<span>PNG, JPEG or WebP · up to 8 MB</span><input id="image-upload" type="file" accept="image/png,image/jpeg,image/webp" hidden></label><img id="image-preview" alt="Uploaded topology" hidden><label>Gate sequence and operating conditions<textarea id="operating-notes" rows="2" placeholder="For example: 4:1, CCM, two commands shifted 180°, D = 0.5"></textarea></label><details><summary>Vision connection</summary><p>Your inference token and image go directly from this browser to the Hugging Face inference provider for this request. Neither is saved.</p><label>Hugging Face inference token<input type="password" id="api-key" autocomplete="off" placeholder="hf_…"></label><label>Vision model<input id="vision-model" value="Qwen/Qwen2.5-VL-72B-Instruct"></label></details><button id="inspect" class="primary" disabled>Read topology →</button><p id="upload-status" role="status">Choose a schematic to begin.</p><div id="interpretation" hidden></div></dialog>
12
  <div id="toast" role="status" hidden></div><script src="./engine.js"></script><script src="./app.js"></script></body></html>
 
1
  <!doctype html>
2
  <html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="description" content="Power converter topologies and their ideal conversion ratio plus effective output resistance."><title>ThinkPower — Topology & Equivalent Circuit</title><link rel="stylesheet" href="./style.css"></head><body>
3
  <header><a class="brand" href="./index.html"><span>╳</span>ThinkPower</a><div>Topology → equivalent circuit</div><a href="https://huggingface.co/spaces/minjiechen/XFLY" target="_blank" rel="noopener">NGSpice ↗</a></header>
4
+ <main><div class="intro"><div><h1>A topology. Its equivalent circuit.</h1><p>Ideal voltage conversion with conduction, charge-sharing, and switching-loss equivalents. Resistance values are per unit of R<sub>S</sub>.</p></div><button id="open-upload">+ Upload topology</button></div>
5
  <section class="toolbar" aria-label="Comparison settings"><div class="ratio-control"><label>Conversion ratio</label><div id="ratios"><button data-ratio="2">2:1</button><button data-ratio="4" class="active">4:1</button><button data-ratio="6">6:1</button><button data-ratio="8">8:1</button><button data-ratio="16">16:1</button></div></div><details class="weights"><summary>Per-unit loss weights</summary><div><label>R<sub>C</sub> / R<sub>S</sub><input id="rho_c" type="number" value="1" min="0" step="0.1"></label><label>R<sub>L</sub> / R<sub>S</sub><input id="rho_l" type="number" value="1" min="0" step="0.1"></label><label>1 / (C<sub>F</sub> f<sub>s</sub> R<sub>S</sub>)<input id="rho_q" type="number" value="20" min="0" step="1"></label><button id="apply-weights">Apply</button><button id="reset">Reset</button></div></details><button id="export-csv" class="plain">↓ CSV</button></section>
6
  <div id="topology-picker" class="picker" aria-label="Topologies to compare"></div><div id="status" role="status" class="status">Loading topology models…</div>
7
  <div class="column-labels"><span>CONVERTER TOPOLOGY</span><span>AVERAGED DC EQUIVALENT CIRCUIT</span></div><section id="circuits" aria-label="Topology and equivalent circuit comparison"></section>
8
  <details id="sweep-section" class="secondary-panel"><summary>Effective resistance versus conversion ratio</summary><div id="legend"></div><div id="rout-chart" class="chart"></div><p>The horizontal axis is the step-down ratio M = Vout/Vin. Only supported duty ranges are plotted.</p></details>
9
+ <details class="secondary-panel" id="model-details"><summary>How the effective resistance is calculated</summary><p>The ideal DC transformer represents the <em>averaged conversion ratio</em>; it does not imply a physical transformer or galvanic isolation. The series resistances are referred to the output. The three green blocks show the coefficient-weighted switch, capacitor-ESR and winding contributions, grouped as R<sub>FSL</sub>.</p><div class="equation">V<sub>out</sub> ≈ M V<sub>in</sub> − I<sub>out</sub> R<sub>eq</sub></div><div class="equation">R<sub>eq</sub> = R<sub>IND</sub> + √[(R<sub>FET</sub> + R<sub>CAP</sub>)² + R<sub>SSL</sub>²]</div><div class="equation">R<sub>FSL</sub> = R<sub>FET</sub> + R<sub>CAP</sub> + R<sub>IND</sub></div><div class="equation">R<sub>SSL,add</sub> = √[(R<sub>FET</sub> + R<sub>CAP</sub>)² + R<sub>SSL</sub>²] − (R<sub>FET</sub> + R<sub>CAP</sub>)</div><div class="equation">R<sub>eq</sub> = R<sub>FSL</sub> + R<sub>SSL,add</sub></div><p>The orange inset gives the estimated charge-sharing limit R<sub>SSL</sub>. The orange series block is its incremental contribution after interpolation. FSL and SSL are limits of the same charging process; they are combined by the paper’s interpolation, rather than added as independent series resistors. All displayed numbers divide resistance by R<sub>S</sub>. Device allocations are fixed at the 4:1 design point with total area 12 A₀.</p><p>Assumptions: two matched flat phase currents, identical device technology, and zero clamp-capacitor ESR. The parallel input branch represents switching loss through R<sub>SW,in</sub> = V<sub>in</sub>²/P<sub>sw</sub>. It needs switching-loss data at the operating point and is shown symbolically; it is excluded from the numerical resistance sweep. Gate drive, magnetic core loss, winding ripple, and dead time are excluded. XFLY2P uses the paper’s effective six-switch model with the physical split-middle area normalization. XFLY4P applies only to the specified four-pulse realization. Unsupported operating points receive no numerical resistance.</p><div id="coefficients"></div></details>
10
  <footer><span>ThinkPower · Based on the XFLY family analysis</span><span>Per-unit analytical model · verify with switched simulation</span></footer></main>
11
  <dialog id="upload-dialog"><div class="dialog-heading"><h2>Upload a topology</h2><button id="close-upload" aria-label="Close upload">×</button></div><label class="dropzone" id="dropzone">Choose or drop a schematic<span>PNG, JPEG or WebP · up to 8 MB</span><input id="image-upload" type="file" accept="image/png,image/jpeg,image/webp" hidden></label><img id="image-preview" alt="Uploaded topology" hidden><label>Gate sequence and operating conditions<textarea id="operating-notes" rows="2" placeholder="For example: 4:1, CCM, two commands shifted 180°, D = 0.5"></textarea></label><details><summary>Vision connection</summary><p>Your inference token and image go directly from this browser to the Hugging Face inference provider for this request. Neither is saved.</p><label>Hugging Face inference token<input type="password" id="api-key" autocomplete="off" placeholder="hf_…"></label><label>Vision model<input id="vision-model" value="Qwen/Qwen2.5-VL-72B-Instruct"></label></details><button id="inspect" class="primary" disabled>Read topology →</button><p id="upload-status" role="status">Choose a schematic to begin.</p><div id="interpretation" hidden></div></dialog>
12
  <div id="toast" role="status" hidden></div><script src="./engine.js"></script><script src="./app.js"></script></body></html>
static/style.css CHANGED
@@ -1,2 +1,4 @@
1
  @import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@500;600;700;800&display=swap');
2
  :root{--ink:#24343c;--muted:#7b898e;--line:#dfe6e2;--teal:#157e70;--paper:#f5f7f4}*{box-sizing:border-box}body{margin:0;background:var(--paper);color:var(--ink);font:14px 'DM Sans',Arial,sans-serif}button,input,textarea{font:inherit}button,summary{cursor:pointer}button{background:white;border:1px solid var(--line);border-radius:6px;padding:9px 13px;color:#53676a;font-size:12px}button:hover{border-color:#84b2a6}button:disabled{opacity:.5;cursor:not-allowed}a{color:inherit;text-decoration:none}header{height:78px;background:white;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;padding:0 5%;gap:25px}header>div,header>a:last-child{font-size:11px;color:var(--muted)}.brand{font:800 23px Manrope,Arial,sans-serif;letter-spacing:-.8px;display:flex;align-items:center;gap:10px}.brand>span{font:28px Arial;background:var(--teal);border-radius:6px;color:white;width:30px;height:32px;display:grid;place-items:center}main{max-width:1350px;margin:auto;padding:40px 5% 0}.intro{display:flex;align-items:center;justify-content:space-between;gap:22px;margin-bottom:29px}h1{font:700 29px Manrope,Arial,sans-serif;letter-spacing:-1px;margin:0 0 11px}.intro p{font-size:12px;color:var(--muted);line-height:1.7;margin:0}.intro>button{white-space:nowrap}.toolbar{display:flex;align-items:center;justify-content:space-between;gap:20px;border:1px solid var(--line);background:white;border-radius:8px;padding:14px 17px;flex-wrap:wrap}.ratio-control{display:flex;align-items:center;gap:18px}.ratio-control>label{color:var(--muted);font-size:11px}#ratios{display:flex;gap:5px}#ratios button{font-size:11px;padding:8px 13px}.active{background:#eaf4ee;color:var(--teal);border-color:#85b5a8;font-weight:700}.weights{margin-left:auto;font-size:11px;color:#71847e}.weights>div{display:flex;gap:12px;align-items:flex-end;margin-top:14px}.weights label{font-size:10px}.weights input{width:105px;display:block;margin-top:5px;padding:7px 9px;border:1px solid var(--line);border-radius:4px;color:var(--ink)}summary{line-height:1.6}.plain{border-color:transparent;color:#7d9085;padding:8px}.picker{display:flex;gap:8px;flex-wrap:wrap;margin:20px 0 10px}.picker button{font-size:10px;border-radius:20px;padding:7px 12px;background:transparent}.picker button.active{background:#e7f0e9}.status{font-size:10px;min-height:25px;color:#8d9a93;margin-bottom:15px}.column-labels{display:grid;grid-template-columns:36% 64%;font-size:9px;letter-spacing:1.4px;color:#93a19a;padding:0 22px 13px}.column-labels span:last-child{padding-left:27px}.circuit-card{display:grid;grid-template-columns:36% 64%;background:white;border:1px solid var(--line);border-radius:9px;margin-bottom:16px;overflow:hidden}.topology{padding:22px;border-right:1px solid var(--line);position:relative}.topology h2{font:700 14px Manrope,Arial,sans-serif;margin:0 0 5px}.topology .sub{font-size:10px;color:#8b9993;min-height:15px}.topology img{width:100%;height:235px;object-fit:contain;display:block;margin-top:12px}.equivalent{padding:20px 22px 15px;min-width:0}.eq-heading{display:flex;justify-content:space-between;align-items:center;font-size:10px;color:#8b9a91}.eq-value{color:var(--teal);font-size:12px;font-weight:700}.equivalent svg{width:100%;height:auto;display:block;margin-top:6px}.eq-caption{display:flex;justify-content:space-between;align-items:center;gap:12px;padding-top:4px}.eq-caption p{font-size:11px;color:#72847a;margin:0;line-height:1.6}.eq-caption button{font-size:9px;padding:5px 8px;white-space:nowrap}.components{display:flex;gap:14px;flex-wrap:wrap;margin-top:12px;padding-top:12px;border-top:1px solid #edf0ed;font-size:10px;color:#8b9991}.components span>b{font-weight:500;color:#61766a}.unsupported{color:#a0814c!important}.secondary-panel{border:1px solid var(--line);border-radius:8px;background:#fff;padding:17px 20px;margin:20px 0;color:#76897d;font-size:11px}.secondary-panel>summary{font-size:12px;color:#536c60}.secondary-panel p{line-height:1.9;margin:15px 0}.equation{font:17px Georgia,serif;line-height:2;color:#526e5b;margin:12px 0}#legend{display:flex;gap:18px;flex-wrap:wrap;margin:22px 0 8px;font-size:10px}#legend i{display:inline-block;width:15px;height:3px;vertical-align:middle;margin-right:6px}.chart{width:100%;height:320px;position:relative}.chart svg{width:100%;height:100%}.chart-tooltip{position:absolute;background:#20352ded;color:white;padding:10px 12px;border-radius:5px;font-size:10px;pointer-events:none;line-height:1.8;z-index:2;white-space:nowrap}.formula{border-top:1px solid var(--line);padding:13px 0;line-height:1.9}.formula code{display:block;font-size:10px;color:#65786a}.formula p{margin:5px 0;font-size:10px}footer{border-top:1px solid var(--line);display:flex;justify-content:space-between;gap:20px;color:#93a294;font-size:10px;padding:25px 0;margin-top:35px;line-height:1.8}sub{font-size:.7em}dialog{border:1px solid var(--line);border-radius:10px;padding:26px;width:620px;max-width:94vw;max-height:90vh;color:var(--ink)}dialog::backdrop{background:#243d3060}.dialog-heading{display:flex;justify-content:space-between;align-items:center;margin-bottom:20px}.dialog-heading h2{font:700 19px Manrope,Arial,sans-serif;margin:0}.dialog-heading button{border:0;font-size:22px;padding:0 7px}.dropzone{display:flex;align-items:center;justify-content:center;flex-direction:column;background:#f4f8f2;border:1px dashed #adc7b6;border-radius:6px;padding:25px;gap:9px;font-size:13px;color:#6c8877;cursor:pointer}.dropzone span{font-size:10px}.dropzone.drag{background:#dcefe0}#image-preview{max-height:200px;object-fit:contain;width:100%;margin:15px 0}dialog>label:not(.dropzone),dialog details label{display:block;font-size:11px;color:#7b8f7f;margin:16px 0}dialog textarea,dialog input:not([type=checkbox]){display:block;width:100%;padding:9px 11px;border:1px solid var(--line);border-radius:5px;margin-top:7px;color:#4c6754;background:#fafcf8}dialog details{font-size:11px;margin:15px 0}dialog p,dialog li{font-size:11px;line-height:1.8;color:#7a8c7c}.primary{background:var(--teal);color:white;border-color:var(--teal)}#interpretation pre{max-height:230px;overflow:auto;white-space:pre-wrap;font:10px/1.7 monospace;background:#f3f6f0;border-radius:5px;padding:12px}#interpretation label{font-size:11px;line-height:1.8;display:flex;gap:8px;align-items:flex-start;margin:15px 0}#toast{position:fixed;bottom:25px;left:50%;transform:translateX(-50%);background:#253d30;color:white;border-radius:6px;padding:13px 20px;max-width:90vw;font-size:12px;z-index:10}[hidden]{display:none!important}@media(max-width:850px){main{padding:28px 4% 0}header{padding:0 4%}.intro{align-items:flex-start}h1{font-size:25px}.toolbar{gap:12px}.weights{margin-left:0}.column-labels{grid-template-columns:34% 66%}.circuit-card{grid-template-columns:34% 66%}.topology{padding:18px}.topology img{height:205px}.equivalent{padding:17px}.eq-value{font-size:11px}.components{gap:9px;font-size:9px}.eq-caption p{font-size:10px}}@media(max-width:600px){header{height:66px}.brand{font-size:21px}header>div{display:none}main{padding-top:25px}.intro{flex-direction:column;gap:13px;margin-bottom:21px}h1{font-size:24px}.ratio-control{width:100%;justify-content:space-between;gap:8px}#ratios{gap:3px}#ratios button{padding:7px 9px;font-size:10px}.weights>div{flex-wrap:wrap;gap:10px}.weights input{width:84px}.picker{gap:5px}.picker button{font-size:9px;padding:6px 9px}.column-labels{display:none}.circuit-card{display:block}.topology{border-right:0;border-bottom:1px solid var(--line);padding:17px}.topology img{height:200px;margin-top:5px}.equivalent{padding:16px 10px}.eq-heading{padding:0 5px;font-size:9px}.eq-value{font-size:10px}.eq-caption,.components{margin-left:6px;margin-right:6px}.eq-caption p{font-size:10px}.components{font-size:9px;gap:12px}.equation{font-size:14px}footer{flex-direction:column;gap:5px}.chart{height:290px}}
 
 
 
1
  @import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@500;600;700;800&display=swap');
2
  :root{--ink:#24343c;--muted:#7b898e;--line:#dfe6e2;--teal:#157e70;--paper:#f5f7f4}*{box-sizing:border-box}body{margin:0;background:var(--paper);color:var(--ink);font:14px 'DM Sans',Arial,sans-serif}button,input,textarea{font:inherit}button,summary{cursor:pointer}button{background:white;border:1px solid var(--line);border-radius:6px;padding:9px 13px;color:#53676a;font-size:12px}button:hover{border-color:#84b2a6}button:disabled{opacity:.5;cursor:not-allowed}a{color:inherit;text-decoration:none}header{height:78px;background:white;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;padding:0 5%;gap:25px}header>div,header>a:last-child{font-size:11px;color:var(--muted)}.brand{font:800 23px Manrope,Arial,sans-serif;letter-spacing:-.8px;display:flex;align-items:center;gap:10px}.brand>span{font:28px Arial;background:var(--teal);border-radius:6px;color:white;width:30px;height:32px;display:grid;place-items:center}main{max-width:1350px;margin:auto;padding:40px 5% 0}.intro{display:flex;align-items:center;justify-content:space-between;gap:22px;margin-bottom:29px}h1{font:700 29px Manrope,Arial,sans-serif;letter-spacing:-1px;margin:0 0 11px}.intro p{font-size:12px;color:var(--muted);line-height:1.7;margin:0}.intro>button{white-space:nowrap}.toolbar{display:flex;align-items:center;justify-content:space-between;gap:20px;border:1px solid var(--line);background:white;border-radius:8px;padding:14px 17px;flex-wrap:wrap}.ratio-control{display:flex;align-items:center;gap:18px}.ratio-control>label{color:var(--muted);font-size:11px}#ratios{display:flex;gap:5px}#ratios button{font-size:11px;padding:8px 13px}.active{background:#eaf4ee;color:var(--teal);border-color:#85b5a8;font-weight:700}.weights{margin-left:auto;font-size:11px;color:#71847e}.weights>div{display:flex;gap:12px;align-items:flex-end;margin-top:14px}.weights label{font-size:10px}.weights input{width:105px;display:block;margin-top:5px;padding:7px 9px;border:1px solid var(--line);border-radius:4px;color:var(--ink)}summary{line-height:1.6}.plain{border-color:transparent;color:#7d9085;padding:8px}.picker{display:flex;gap:8px;flex-wrap:wrap;margin:20px 0 10px}.picker button{font-size:10px;border-radius:20px;padding:7px 12px;background:transparent}.picker button.active{background:#e7f0e9}.status{font-size:10px;min-height:25px;color:#8d9a93;margin-bottom:15px}.column-labels{display:grid;grid-template-columns:36% 64%;font-size:9px;letter-spacing:1.4px;color:#93a19a;padding:0 22px 13px}.column-labels span:last-child{padding-left:27px}.circuit-card{display:grid;grid-template-columns:36% 64%;background:white;border:1px solid var(--line);border-radius:9px;margin-bottom:16px;overflow:hidden}.topology{padding:22px;border-right:1px solid var(--line);position:relative}.topology h2{font:700 14px Manrope,Arial,sans-serif;margin:0 0 5px}.topology .sub{font-size:10px;color:#8b9993;min-height:15px}.topology img{width:100%;height:235px;object-fit:contain;display:block;margin-top:12px}.equivalent{padding:20px 22px 15px;min-width:0}.eq-heading{display:flex;justify-content:space-between;align-items:center;font-size:10px;color:#8b9a91}.eq-value{color:var(--teal);font-size:12px;font-weight:700}.equivalent svg{width:100%;height:auto;display:block;margin-top:6px}.eq-caption{display:flex;justify-content:space-between;align-items:center;gap:12px;padding-top:4px}.eq-caption p{font-size:11px;color:#72847a;margin:0;line-height:1.6}.eq-caption button{font-size:9px;padding:5px 8px;white-space:nowrap}.components{display:flex;gap:14px;flex-wrap:wrap;margin-top:12px;padding-top:12px;border-top:1px solid #edf0ed;font-size:10px;color:#8b9991}.components span>b{font-weight:500;color:#61766a}.unsupported{color:#a0814c!important}.secondary-panel{border:1px solid var(--line);border-radius:8px;background:#fff;padding:17px 20px;margin:20px 0;color:#76897d;font-size:11px}.secondary-panel>summary{font-size:12px;color:#536c60}.secondary-panel p{line-height:1.9;margin:15px 0}.equation{font:17px Georgia,serif;line-height:2;color:#526e5b;margin:12px 0}#legend{display:flex;gap:18px;flex-wrap:wrap;margin:22px 0 8px;font-size:10px}#legend i{display:inline-block;width:15px;height:3px;vertical-align:middle;margin-right:6px}.chart{width:100%;height:320px;position:relative}.chart svg{width:100%;height:100%}.chart-tooltip{position:absolute;background:#20352ded;color:white;padding:10px 12px;border-radius:5px;font-size:10px;pointer-events:none;line-height:1.8;z-index:2;white-space:nowrap}.formula{border-top:1px solid var(--line);padding:13px 0;line-height:1.9}.formula code{display:block;font-size:10px;color:#65786a}.formula p{margin:5px 0;font-size:10px}footer{border-top:1px solid var(--line);display:flex;justify-content:space-between;gap:20px;color:#93a294;font-size:10px;padding:25px 0;margin-top:35px;line-height:1.8}sub{font-size:.7em}dialog{border:1px solid var(--line);border-radius:10px;padding:26px;width:620px;max-width:94vw;max-height:90vh;color:var(--ink)}dialog::backdrop{background:#243d3060}.dialog-heading{display:flex;justify-content:space-between;align-items:center;margin-bottom:20px}.dialog-heading h2{font:700 19px Manrope,Arial,sans-serif;margin:0}.dialog-heading button{border:0;font-size:22px;padding:0 7px}.dropzone{display:flex;align-items:center;justify-content:center;flex-direction:column;background:#f4f8f2;border:1px dashed #adc7b6;border-radius:6px;padding:25px;gap:9px;font-size:13px;color:#6c8877;cursor:pointer}.dropzone span{font-size:10px}.dropzone.drag{background:#dcefe0}#image-preview{max-height:200px;object-fit:contain;width:100%;margin:15px 0}dialog>label:not(.dropzone),dialog details label{display:block;font-size:11px;color:#7b8f7f;margin:16px 0}dialog textarea,dialog input:not([type=checkbox]){display:block;width:100%;padding:9px 11px;border:1px solid var(--line);border-radius:5px;margin-top:7px;color:#4c6754;background:#fafcf8}dialog details{font-size:11px;margin:15px 0}dialog p,dialog li{font-size:11px;line-height:1.8;color:#7a8c7c}.primary{background:var(--teal);color:white;border-color:var(--teal)}#interpretation pre{max-height:230px;overflow:auto;white-space:pre-wrap;font:10px/1.7 monospace;background:#f3f6f0;border-radius:5px;padding:12px}#interpretation label{font-size:11px;line-height:1.8;display:flex;gap:8px;align-items:flex-start;margin:15px 0}#toast{position:fixed;bottom:25px;left:50%;transform:translateX(-50%);background:#253d30;color:white;border-radius:6px;padding:13px 20px;max-width:90vw;font-size:12px;z-index:10}[hidden]{display:none!important}@media(max-width:850px){main{padding:28px 4% 0}header{padding:0 4%}.intro{align-items:flex-start}h1{font-size:25px}.toolbar{gap:12px}.weights{margin-left:0}.column-labels{grid-template-columns:34% 66%}.circuit-card{grid-template-columns:34% 66%}.topology{padding:18px}.topology img{height:205px}.equivalent{padding:17px}.eq-value{font-size:11px}.components{gap:9px;font-size:9px}.eq-caption p{font-size:10px}}@media(max-width:600px){header{height:66px}.brand{font-size:21px}header>div{display:none}main{padding-top:25px}.intro{flex-direction:column;gap:13px;margin-bottom:21px}h1{font-size:24px}.ratio-control{width:100%;justify-content:space-between;gap:8px}#ratios{gap:3px}#ratios button{padding:7px 9px;font-size:10px}.weights>div{flex-wrap:wrap;gap:10px}.weights input{width:84px}.picker{gap:5px}.picker button{font-size:9px;padding:6px 9px}.column-labels{display:none}.circuit-card{display:block}.topology{border-right:0;border-bottom:1px solid var(--line);padding:17px}.topology img{height:200px;margin-top:5px}.equivalent{padding:16px 10px}.eq-heading{padding:0 5px;font-size:9px}.eq-value{font-size:10px}.eq-caption,.components{margin-left:6px;margin-right:6px}.eq-caption p{font-size:10px}.components{font-size:9px;gap:12px}.equation{font-size:14px}footer{flex-direction:column;gap:5px}.chart{height:290px}}
3
+
4
+ .equivalent-drawing{overflow-x:auto}.equivalent-drawing svg{min-width:650px}.scroll-note{display:none}.equation{overflow-wrap:anywhere}@media(max-width:600px){.scroll-note{display:block;color:#8b9993;font-size:9px;margin:6px}}
test_per_unit.py CHANGED
@@ -33,6 +33,18 @@ class PerUnitTest(unittest.TestCase):
33
  def test_reject_invalid_dimensionless_scale(self):
34
  for p in [{'rho_c':-1},{'rho_l':float('nan')},{'rho_q':float('inf')}]:
35
  with self.assertRaises(ValueError):analyze_pu(p)
 
 
 
 
 
 
 
 
 
 
 
 
36
  def test_custom_states_produce_coefficients(self):
37
  d=state_model_pu(dict(states=[dict(fraction=.5,switch_currents=[1,0],capacitor_currents=[.5],inductor_currents=[.5,.5]),dict(fraction=.5,switch_currents=[0,1],capacitor_currents=[-.5],inductor_currents=[.5,.5])]))
38
  self.assertAlmostEqual(d['k_fet'],1/6);self.assertEqual(d['k_cap'],.25);self.assertEqual(d['k_ind'],.5)
 
33
  def test_reject_invalid_dimensionless_scale(self):
34
  for p in [{'rho_c':-1},{'rho_l':float('nan')},{'rho_q':float('inf')}]:
35
  with self.assertRaises(ValueError):analyze_pu(p)
36
+ def test_series_charging_increment_preserves_interpolated_total(self):
37
+ for ratio in [2,2.1,3,4,6,8,16]:
38
+ for q in [0,1e-6,20,1e6]:
39
+ for r in analyze_pu(dict(ratio=ratio,rho_q=q))['rows']:
40
+ if not r['valid']:continue
41
+ self.assertGreaterEqual(r['ssl_series'],0)
42
+ self.assertAlmostEqual(r['fsl']+r['ssl_series'],r['total'])
43
+ if not r['ssl']:self.assertEqual(r['ssl_series'],0)
44
+ r=next(r for r in analyze_pu({})['rows'] if r['id']=='2sbuck')
45
+ self.assertAlmostEqual(r['ssl'],.625)
46
+ self.assertAlmostEqual(r['ssl_series'],.3003905296791061)
47
+ self.assertNotEqual(r['ssl'],r['ssl_series'])
48
  def test_custom_states_produce_coefficients(self):
49
  d=state_model_pu(dict(states=[dict(fraction=.5,switch_currents=[1,0],capacitor_currents=[.5],inductor_currents=[.5,.5]),dict(fraction=.5,switch_currents=[0,1],capacitor_currents=[-.5],inductor_currents=[.5,.5])]))
50
  self.assertAlmostEqual(d['k_fet'],1/6);self.assertEqual(d['k_cap'],.25);self.assertEqual(d['k_ind'],.5)