Appearance
🐍 SWB API 参考
Sentaurus Workbench Python 自动化接口 (swbpy2)
概述
SWB API(swbpy2)提供 Python 接口用于操作 Sentaurus Workbench 项目,支持自动化仿真流程。
核心类
Deck - 项目管理器
打开、创建、预处理、运行项目。
python
from swbpy2 import Deck
# 打开项目
deck = Deck('/path/to/project')
# 预处理
deck.preprocess()
# 运行
deck.run()
# 查询状态
tree = deck.getGtree()
status = tree.NodeStatus(node_id)Gtree - 仿真树
管理仿真树中的节点、实验、参数、变量。
python
# 获取仿真树
tree = deck.getGtree()
# 添加实验路径
tree.AddPath(pvalues=[1.0, 2.0, 3.0])
# 获取节点列表
nodes = tree.GetAllNodes()
# 查询节点状态
status = tree.NodeStatus(node_id)
print(status) # e.g., "finished", "running", "pending"Tool - 工具包装器
操作工具参数、编辑 cmd 文件。
python
# 获取工具
tool = tree.GetTool(tool_name)
# 设置参数
tool.SetParameter('Temperature', 300)
# 编辑 cmd 文件内容
cmd = tool.GetCmd()
cmd['Solve']['Coupled'] = '{ Poisson Electron }'
tool.SetCmd(cmd)完整示例
python
from swbpy2 import Deck
import time
# 打开项目
deck = Deck('/project/mosfet_swb')
# 获取仿真树
tree = deck.getGtree()
# 创建新实验
exp = tree.AddExperiment()
# 设置参数
tool = tree.GetTool('sdevice')
tool.SetParameter('Vgs', 0.8)
# 预处理并运行
deck.preprocess()
deck.run()
# 轮询等待完成
while True:
status = tree.NodeStatus(exp.id)
if status == 'finished':
print('仿真完成')
break
elif status == 'failed':
print('仿真失败')
break
time.sleep(30)安装
bash
pip install swbpy2