Spaces:
Running
Running
Deploy Xfly/C3L comparison GUI
Browse files
library/ngspice/studies/xfly6s_xfly8s_c3l_scaled_comparison/gui/xfly_compare_gui.py
CHANGED
|
@@ -52,6 +52,8 @@ DEFAULT_CFLY_NF = 100.0
|
|
| 52 |
DEFAULT_SWITCHING_FREQUENCY_MHZ = 100.0
|
| 53 |
DEFAULT_FREQUENCY_BY_TOPOLOGY_MHZ = {"xfly6s": 100.0, "xfly8s": 50.0, "c3l": 50.0}
|
| 54 |
DEFAULT_MAX_STEP_PS = 200.0
|
|
|
|
|
|
|
| 55 |
COUT = 100e-9
|
| 56 |
CIN = 1e-6
|
| 57 |
MIN_DUTY = 0.12
|
|
@@ -60,6 +62,7 @@ MAX_DUTY = 0.78
|
|
| 60 |
TOPOLOGIES: dict[str, dict[str, Any]] = {
|
| 61 |
"xfly6s": {
|
| 62 |
"label": "Xfly6S",
|
|
|
|
| 63 |
"duty_gain": 0.9683,
|
| 64 |
"template": NETLIST_DIR / "xfly6s_transient.cir",
|
| 65 |
"raw_old": "output/xfly6s_transient/xfly6s_transient.raw",
|
|
@@ -84,6 +87,7 @@ TOPOLOGIES: dict[str, dict[str, Any]] = {
|
|
| 84 |
},
|
| 85 |
"c3l": {
|
| 86 |
"label": "C3L",
|
|
|
|
| 87 |
"duty_gain": 0.9566,
|
| 88 |
"template": NETLIST_DIR / "c3l_transient.cir",
|
| 89 |
"raw_old": "output/c3l_transient/c3l_transient.raw",
|
|
@@ -110,6 +114,7 @@ TOPOLOGIES: dict[str, dict[str, Any]] = {
|
|
| 110 |
},
|
| 111 |
"xfly8s": {
|
| 112 |
"label": "Xfly8S",
|
|
|
|
| 113 |
"duty_gain": 0.9600,
|
| 114 |
"template": NETLIST_DIR / "xfly8s_transient.cir",
|
| 115 |
"raw_old": "output/xfly8s_transient/xfly8s_transient.raw",
|
|
@@ -624,6 +629,16 @@ HTML = r"""<!doctype html>
|
|
| 624 |
<input id="coff" name="coff" type="number" min="0" max="500" step="1" value="20">
|
| 625 |
</div>
|
| 626 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 627 |
<div class="two">
|
| 628 |
<div class="control">
|
| 629 |
<label for="stop">Stop Time (us)</label>
|
|
@@ -683,6 +698,7 @@ HTML = r"""<!doctype html>
|
|
| 683 |
<th>Topology</th>
|
| 684 |
<th>Inferred Duty</th>
|
| 685 |
<th>Efficiency (%)</th>
|
|
|
|
| 686 |
<th>Vout Avg (V)</th>
|
| 687 |
<th>Iout Avg (A)</th>
|
| 688 |
<th>IL1 Avg (A)</th>
|
|
@@ -763,6 +779,7 @@ HTML = r"""<!doctype html>
|
|
| 763 |
<td>${item.label}</td>
|
| 764 |
<td>${fmt(item.inferred_duty, 4)}</td>
|
| 765 |
<td>${fmt(item.efficiency_pct, 2)}</td>
|
|
|
|
| 766 |
<td>${fmt(item.vout_avg, 5)}</td>
|
| 767 |
<td>${fmt(item.iout_load_avg, 4)}</td>
|
| 768 |
<td>${fmt(item.il1_avg, 4)}</td>
|
|
@@ -970,6 +987,8 @@ HTML = r"""<!doctype html>
|
|
| 970 |
dcr2_mohm: Number(document.getElementById('dcr2').value),
|
| 971 |
switch_ron_mohm: Number(document.getElementById('ron').value),
|
| 972 |
switch_coff_pf: Number(document.getElementById('coff').value),
|
|
|
|
|
|
|
| 973 |
stop_us: Number(document.getElementById('stop').value),
|
| 974 |
max_step_ps: Number(document.getElementById('step').value),
|
| 975 |
topologies,
|
|
@@ -1114,6 +1133,7 @@ def prepare_deck(topology: str, settings: dict[str, float], run_dir: Path, case_
|
|
| 1114 |
step = f"{settings['max_step_ps']:.6g}p"
|
| 1115 |
|
| 1116 |
text = replace_param(text, "VIN", f"{settings['input_voltage_v']:.6g}")
|
|
|
|
| 1117 |
text = replace_switching_frequency(text, settings["frequency_by_topology_mhz"][topology])
|
| 1118 |
text = replace_param(text, "VOUT_TARGET", f"{settings['target_vout']:.6g}")
|
| 1119 |
text = replace_param(text, "IOUT_NOM", f"{settings['iout_target']:.6g}")
|
|
@@ -1224,6 +1244,13 @@ def finite_or_none(value: float) -> float | None:
|
|
| 1224 |
return float(value) if np.isfinite(value) else None
|
| 1225 |
|
| 1226 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1227 |
def storage_delta_power(
|
| 1228 |
t: np.ndarray,
|
| 1229 |
mask: np.ndarray,
|
|
@@ -1280,8 +1307,10 @@ def analyze_case(topology: str, run_dir: Path, settings: dict[str, float], case_
|
|
| 1280 |
pin_avg = time_average(t, pin, mask)
|
| 1281 |
pout_avg = time_average(t, pout, mask)
|
| 1282 |
p_storage = storage_delta_power(t, mask, cin, co, caps, il1, il2, settings)
|
| 1283 |
-
|
| 1284 |
-
|
|
|
|
|
|
|
| 1285 |
|
| 1286 |
return {
|
| 1287 |
"key": topology,
|
|
@@ -1301,9 +1330,11 @@ def analyze_case(topology: str, run_dir: Path, settings: dict[str, float], case_
|
|
| 1301 |
"vout_pp": peak_to_peak(vout[mask]),
|
| 1302 |
"iout_load_avg": time_average(t, vout, mask) / settings["rload"],
|
| 1303 |
"iout_inductor_sum_avg": iout_avg,
|
| 1304 |
-
"pin_avg": finite_or_none(
|
|
|
|
| 1305 |
"pin_source_avg": finite_or_none(pin_avg),
|
| 1306 |
"storage_delta_power": finite_or_none(p_storage),
|
|
|
|
| 1307 |
"pout_avg": finite_or_none(pout_avg),
|
| 1308 |
"efficiency_pct": finite_or_none(efficiency_pct),
|
| 1309 |
"iout_pp": peak_to_peak(iout[mask]),
|
|
@@ -1346,7 +1377,8 @@ def make_plot(cases: list[dict[str, Any]], run_dir: Path, settings: dict[str, fl
|
|
| 1346 |
f"{freq_text}; "
|
| 1347 |
f"L={settings['lout_nh']:.2f} nH, Cfly={settings['cfly_nf']:.1f} nF, "
|
| 1348 |
f"L1/L2 DCR={settings['dcr1_mohm']:.1f}/{settings['dcr2_mohm']:.1f} mohm, "
|
| 1349 |
-
f"Ron={settings['switch_ron_mohm']:.1f} mohm, Coss={settings['switch_coff_pf']:.1f} pF
|
|
|
|
| 1350 |
),
|
| 1351 |
fontsize=10,
|
| 1352 |
fontweight="bold",
|
|
@@ -1434,6 +1466,8 @@ def settings_from_payload(payload: dict[str, Any], topologies: list[str]) -> dic
|
|
| 1434 |
"dcr2_mohm": clamp_float(payload.get("dcr2_mohm"), 1.0, 100.0, 20.0),
|
| 1435 |
"switch_ron_mohm": clamp_float(payload.get("switch_ron_mohm"), 0.2, 100.0, 30.0),
|
| 1436 |
"switch_coff_pf": clamp_float(payload.get("switch_coff_pf"), 0.0, 500.0, 20.0),
|
|
|
|
|
|
|
| 1437 |
"stop_us": stop_us,
|
| 1438 |
"max_step_ps": clamp_float(payload.get("max_step_ps"), 5.0, 200.0, DEFAULT_MAX_STEP_PS),
|
| 1439 |
"measure_from_us": max(0.0, stop_us - measure_width_us),
|
|
@@ -1691,6 +1725,8 @@ def main() -> None:
|
|
| 1691 |
"dcr2_mohm": 20,
|
| 1692 |
"switch_ron_mohm": 30,
|
| 1693 |
"switch_coff_pf": 20,
|
|
|
|
|
|
|
| 1694 |
"stop_us": 4.0,
|
| 1695 |
"max_step_ps": DEFAULT_MAX_STEP_PS,
|
| 1696 |
"topologies": ["xfly6s", "xfly8s", "c3l"],
|
|
|
|
| 52 |
DEFAULT_SWITCHING_FREQUENCY_MHZ = 100.0
|
| 53 |
DEFAULT_FREQUENCY_BY_TOPOLOGY_MHZ = {"xfly6s": 100.0, "xfly8s": 50.0, "c3l": 50.0}
|
| 54 |
DEFAULT_MAX_STEP_PS = 200.0
|
| 55 |
+
DEFAULT_GATE_DRIVE_V = 1.8
|
| 56 |
+
DEFAULT_GATE_CAP_PF = 10.0
|
| 57 |
COUT = 100e-9
|
| 58 |
CIN = 1e-6
|
| 59 |
MIN_DUTY = 0.12
|
|
|
|
| 62 |
TOPOLOGIES: dict[str, dict[str, Any]] = {
|
| 63 |
"xfly6s": {
|
| 64 |
"label": "Xfly6S",
|
| 65 |
+
"switch_count": 6,
|
| 66 |
"duty_gain": 0.9683,
|
| 67 |
"template": NETLIST_DIR / "xfly6s_transient.cir",
|
| 68 |
"raw_old": "output/xfly6s_transient/xfly6s_transient.raw",
|
|
|
|
| 87 |
},
|
| 88 |
"c3l": {
|
| 89 |
"label": "C3L",
|
| 90 |
+
"switch_count": 8,
|
| 91 |
"duty_gain": 0.9566,
|
| 92 |
"template": NETLIST_DIR / "c3l_transient.cir",
|
| 93 |
"raw_old": "output/c3l_transient/c3l_transient.raw",
|
|
|
|
| 114 |
},
|
| 115 |
"xfly8s": {
|
| 116 |
"label": "Xfly8S",
|
| 117 |
+
"switch_count": 8,
|
| 118 |
"duty_gain": 0.9600,
|
| 119 |
"template": NETLIST_DIR / "xfly8s_transient.cir",
|
| 120 |
"raw_old": "output/xfly8s_transient/xfly8s_transient.raw",
|
|
|
|
| 629 |
<input id="coff" name="coff" type="number" min="0" max="500" step="1" value="20">
|
| 630 |
</div>
|
| 631 |
</div>
|
| 632 |
+
<div class="two">
|
| 633 |
+
<div class="control">
|
| 634 |
+
<label for="gateDrive">Gate Drive Voltage (V)</label>
|
| 635 |
+
<input id="gateDrive" name="gateDrive" type="number" min="1" max="10" step="0.1" value="1.8">
|
| 636 |
+
</div>
|
| 637 |
+
<div class="control">
|
| 638 |
+
<label for="gateCap">Gate Capacitance (pF)</label>
|
| 639 |
+
<input id="gateCap" name="gateCap" type="number" min="0" max="1000" step="1" value="10">
|
| 640 |
+
</div>
|
| 641 |
+
</div>
|
| 642 |
<div class="two">
|
| 643 |
<div class="control">
|
| 644 |
<label for="stop">Stop Time (us)</label>
|
|
|
|
| 698 |
<th>Topology</th>
|
| 699 |
<th>Inferred Duty</th>
|
| 700 |
<th>Efficiency (%)</th>
|
| 701 |
+
<th>Gate Loss (mW)</th>
|
| 702 |
<th>Vout Avg (V)</th>
|
| 703 |
<th>Iout Avg (A)</th>
|
| 704 |
<th>IL1 Avg (A)</th>
|
|
|
|
| 779 |
<td>${item.label}</td>
|
| 780 |
<td>${fmt(item.inferred_duty, 4)}</td>
|
| 781 |
<td>${fmt(item.efficiency_pct, 2)}</td>
|
| 782 |
+
<td>${fmt(item.gate_loss_w * 1000, 2)}</td>
|
| 783 |
<td>${fmt(item.vout_avg, 5)}</td>
|
| 784 |
<td>${fmt(item.iout_load_avg, 4)}</td>
|
| 785 |
<td>${fmt(item.il1_avg, 4)}</td>
|
|
|
|
| 987 |
dcr2_mohm: Number(document.getElementById('dcr2').value),
|
| 988 |
switch_ron_mohm: Number(document.getElementById('ron').value),
|
| 989 |
switch_coff_pf: Number(document.getElementById('coff').value),
|
| 990 |
+
gate_drive_v: Number(document.getElementById('gateDrive').value),
|
| 991 |
+
gate_cap_pf: Number(document.getElementById('gateCap').value),
|
| 992 |
stop_us: Number(document.getElementById('stop').value),
|
| 993 |
max_step_ps: Number(document.getElementById('step').value),
|
| 994 |
topologies,
|
|
|
|
| 1133 |
step = f"{settings['max_step_ps']:.6g}p"
|
| 1134 |
|
| 1135 |
text = replace_param(text, "VIN", f"{settings['input_voltage_v']:.6g}")
|
| 1136 |
+
text = replace_param(text, "VDRV", f"{settings['gate_drive_v']:.6g}")
|
| 1137 |
text = replace_switching_frequency(text, settings["frequency_by_topology_mhz"][topology])
|
| 1138 |
text = replace_param(text, "VOUT_TARGET", f"{settings['target_vout']:.6g}")
|
| 1139 |
text = replace_param(text, "IOUT_NOM", f"{settings['iout_target']:.6g}")
|
|
|
|
| 1244 |
return float(value) if np.isfinite(value) else None
|
| 1245 |
|
| 1246 |
|
| 1247 |
+
def gate_drive_loss(topology: str, settings: dict[str, float]) -> float:
|
| 1248 |
+
switch_count = float(TOPOLOGIES[topology]["switch_count"])
|
| 1249 |
+
fsw_hz = settings["frequency_by_topology_mhz"][topology] * 1e6
|
| 1250 |
+
gate_cap_f = settings["gate_cap_pf"] * 1e-12
|
| 1251 |
+
return switch_count * gate_cap_f * settings["gate_drive_v"] ** 2 * fsw_hz
|
| 1252 |
+
|
| 1253 |
+
|
| 1254 |
def storage_delta_power(
|
| 1255 |
t: np.ndarray,
|
| 1256 |
mask: np.ndarray,
|
|
|
|
| 1307 |
pin_avg = time_average(t, pin, mask)
|
| 1308 |
pout_avg = time_average(t, pout, mask)
|
| 1309 |
p_storage = storage_delta_power(t, mask, cin, co, caps, il1, il2, settings)
|
| 1310 |
+
pin_power_stage_avg = pin_avg - p_storage
|
| 1311 |
+
p_gate = gate_drive_loss(topology, settings)
|
| 1312 |
+
pin_total_avg = pin_power_stage_avg + p_gate
|
| 1313 |
+
efficiency_pct = 100.0 * pout_avg / pin_total_avg if pin_total_avg > 0.0 else float("nan")
|
| 1314 |
|
| 1315 |
return {
|
| 1316 |
"key": topology,
|
|
|
|
| 1330 |
"vout_pp": peak_to_peak(vout[mask]),
|
| 1331 |
"iout_load_avg": time_average(t, vout, mask) / settings["rload"],
|
| 1332 |
"iout_inductor_sum_avg": iout_avg,
|
| 1333 |
+
"pin_avg": finite_or_none(pin_total_avg),
|
| 1334 |
+
"pin_power_stage_avg": finite_or_none(pin_power_stage_avg),
|
| 1335 |
"pin_source_avg": finite_or_none(pin_avg),
|
| 1336 |
"storage_delta_power": finite_or_none(p_storage),
|
| 1337 |
+
"gate_loss_w": finite_or_none(p_gate),
|
| 1338 |
"pout_avg": finite_or_none(pout_avg),
|
| 1339 |
"efficiency_pct": finite_or_none(efficiency_pct),
|
| 1340 |
"iout_pp": peak_to_peak(iout[mask]),
|
|
|
|
| 1377 |
f"{freq_text}; "
|
| 1378 |
f"L={settings['lout_nh']:.2f} nH, Cfly={settings['cfly_nf']:.1f} nF, "
|
| 1379 |
f"L1/L2 DCR={settings['dcr1_mohm']:.1f}/{settings['dcr2_mohm']:.1f} mohm, "
|
| 1380 |
+
f"Ron={settings['switch_ron_mohm']:.1f} mohm, Coss={settings['switch_coff_pf']:.1f} pF, "
|
| 1381 |
+
f"Vdrv={settings['gate_drive_v']:.2f} V, Cgate={settings['gate_cap_pf']:.1f} pF; {duty_text}"
|
| 1382 |
),
|
| 1383 |
fontsize=10,
|
| 1384 |
fontweight="bold",
|
|
|
|
| 1466 |
"dcr2_mohm": clamp_float(payload.get("dcr2_mohm"), 1.0, 100.0, 20.0),
|
| 1467 |
"switch_ron_mohm": clamp_float(payload.get("switch_ron_mohm"), 0.2, 100.0, 30.0),
|
| 1468 |
"switch_coff_pf": clamp_float(payload.get("switch_coff_pf"), 0.0, 500.0, 20.0),
|
| 1469 |
+
"gate_drive_v": clamp_float(payload.get("gate_drive_v"), 1.0, 10.0, DEFAULT_GATE_DRIVE_V),
|
| 1470 |
+
"gate_cap_pf": clamp_float(payload.get("gate_cap_pf"), 0.0, 1000.0, DEFAULT_GATE_CAP_PF),
|
| 1471 |
"stop_us": stop_us,
|
| 1472 |
"max_step_ps": clamp_float(payload.get("max_step_ps"), 5.0, 200.0, DEFAULT_MAX_STEP_PS),
|
| 1473 |
"measure_from_us": max(0.0, stop_us - measure_width_us),
|
|
|
|
| 1725 |
"dcr2_mohm": 20,
|
| 1726 |
"switch_ron_mohm": 30,
|
| 1727 |
"switch_coff_pf": 20,
|
| 1728 |
+
"gate_drive_v": DEFAULT_GATE_DRIVE_V,
|
| 1729 |
+
"gate_cap_pf": DEFAULT_GATE_CAP_PF,
|
| 1730 |
"stop_us": 4.0,
|
| 1731 |
"max_step_ps": DEFAULT_MAX_STEP_PS,
|
| 1732 |
"topologies": ["xfly6s", "xfly8s", "c3l"],
|