ThinkPower / static /scoreboard.js
minjiechen's picture
Publish ThinkPower topology analysis website
17f4b23 verified
Raw History Blame Contribute Delete
2.45 kB
/* Relative scorecards; physical loss sums remain the primary evidence. */
(function(root){'use strict';
const mechanisms=[{id:'fet',name:'MOSFET conduction',short:'Switch loss',symbol:'S',color:'#4977c8'},{id:'cap',name:'Capacitor ESR',short:'Capacitor loss',symbol:'C',color:'#35a898'},{id:'ind',name:'Winding DCR',short:'Winding loss',symbol:'L',color:'#b88a3c'},{id:'charging',name:'Charging increment',short:'Charging loss',symbol:'Q',color:'#b96b86'},{id:'gate',name:'Gate drive',short:'Gate-drive loss',symbol:'G',color:'#8671b4'}];
function build(report){const io=report.output_current,rows=report.eligible.map(r=>{const powers={fet:io*io*r.parts.fet,cap:io*io*r.parts.cap,ind:io*io*r.parts.ind,charging:io*io*Math.max(0,r.req-r.parts.fsl),gate:r.gate_power};return {id:r.id,total:r.loss,powers,ratings:{},unknown:{coss:null,core_ripple:null}}});
const ranges=Object.fromEntries(mechanisms.map(m=>{const v=rows.map(r=>r.powers[m.id]);return [m.id,{min:Math.min(...v),max:Math.max(...v)}]}));
for(const r of rows){for(const m of mechanisms){const {min,max}=ranges[m.id];r.ratings[m.id]=rows.length<2?null:Math.abs(max-min)<=Math.max(1e-12,max*1e-10)?99:Math.round(99*(max-r.powers[m.id])/(max-min))}const gains=mechanisms.map(m=>{const others=rows.filter(a=>a!==r);return {id:m.id,label:m.short,delta:others.length?others.reduce((s,a)=>s+a.powers[m.id],0)/others.length-r.powers[m.id]:0}});const good=gains.filter(a=>a.delta>1e-9).sort((a,b)=>b.delta-a.delta)[0],bad=gains.filter(a=>a.delta< -1e-9).sort((a,b)=>a.delta-b.delta)[0];r.pro_delta=good?good.delta:null;r.con_delta=bad?-bad.delta:null;r.pro=good?'Lower '+good.label.toLowerCase():rows.length<2?'Only one qualified candidate':'No lower-loss category';r.con=bad?'Higher '+bad.label.toLowerCase():rows.length<2?'No relative comparison available':'No higher-loss category';}
return {mechanisms,rows,scale:'Ratings 0–99 within this displayed set, per mechanism: 99 = lowest modeled loss; 0 = highest. Ties = 99. One candidate = no relative score. These are not efficiency percentages.',unknowns:'Coss, core and ripple-loss corrections are not quantified or included in the modeled total.',charging_definition:'Charging increment = Iout² (Req − RFSL), not the raw SSL asymptote. It is nonoverlapping with the FSL terms.'};}
const api={build,mechanisms};root.ThinkPowerScores=api;if(typeof module!=='undefined')module.exports=api;
})(typeof window!=='undefined'?window:globalThis);