NGspice 降压电源环路仿真
生成降压变换器平均模型网表,用 NGspice 做 AC 环路增益仿真,自动提取穿越频率、相位裕度与增益裕度并输出契约报告。
Badges only claim the demo-run passed on that host; cross-host installation is handled by the adapter layer.
Script environment
- ngspice ≥ 42
- node ≥ 20
Dependencies
- LM2596 降压电源原理图Schematic
^1.0.0OptionalNot installed
SKILL.md
Content matches the files inside the package; extracted by the publish pipeline.
NGspice 降压电源环路仿真
用 CCM 平均模型评估降压变换器(如 LM2596 外接补偿、同步 Buck 控制器) 的环路稳定性:穿越频率 fc、相位裕度 PM、增益裕度 GM。
1. Brief 确认
向用户确认:Vin、Vout、Iout、L、Cout、ESR、开关频率 fsw、补偿类型 (本包内置 Type II / OTA 补偿,适合电压模式或外部补偿电流模式)。 参数可来自 kicad-lm2596-buck Skill 的 design_calc.py 输出。
2. 生成网表
node scripts/gen_netlist.mjs --vin 12 --vout 5 --iout 2 \
--l 33u --c 220u --esr 30m --fsw 150k --out buck-loop.cir
模型说明见 references/averaged-model.md:开关级用受控源 Esw = Vin × duty 平均化,OTA + Type II 网络做误差放大器, 大电感断环 + 大电容注入实现 AC 开环、DC 闭环。
3. 运行仿真
ngspice -b -o buck-loop.log buck-loop.cir
ngspice --version # 记录实际版本
仿真不收敛时:先检查 .param 数值单位(33u 不是 33µ),再把 .ac 起点从 10 Hz 降到 1 Hz。禁止改测量定义来"造"裕度。
4. 判读结果
node scripts/parse_sim.mjs buck-loop.log --tool-version 42 \
--out sim-report.json
parse_sim.mjs 提取 .meas 结果并给出判定:
- PM ≥ 45° 且 GM ≥ 10 dB:pass
- 30° ≤ PM < 45° 或 GM < 10 dB:warning(建议调整补偿)
- PM < 30°:error(有振荡风险,必须改补偿)
fc 建议落在 fsw/10 附近。不达标时按 references/averaged-model.md 的 Type II 调参步骤改 Rz/Cz/Cp 后重跑,把每轮报告展示给用户。
Rules
- 报告只能来自真实 ngspice 运行日志;没有 NGspice 时明确告知用户 如何安装,不得编造裕度数值。
- 不打印、不存储任何 API key;本 Skill 不需要第三方凭证。
- 平均模型只适用于 CCM;轻载 DCM、电流模式次谐波振荡不在本模型 范围内,必须向用户声明。
- 仿真结论不等于硬件实测;交付时提醒用户用频响分析仪或负载阶跃 实测复核。
Package files
references/
scripts/
- ngspice-buck-loop-sim/scripts/gen_netlist.mjs2.4 KB
- ngspice-buck-loop-sim/scripts/parse_sim.mjs2.6 KB
Demo run
Ratings & reviews
Not rated0 ratings
Sign in to rate this skill.
Sign inVersions
- v1.0.0Latest5.9 KB
首发种子版本。