【问题标题】:Automatically quitting ngspice after simulation模拟后自动退出ngspice
【发布时间】:2019-11-15 09:57:27
【问题描述】:

我正在从事一个自动化项目,该项目需要我在 ngspice 中启动模拟,在 .txt 文件中获取数据并退出 ngspice。我有以下代码可以调用 ngspice:

import sys
import os

def invoke_ngspice():
    os.system(r"C:\Users\MyPC\Desktop\GUI\ngspice\bin\ngspice_con.exe C:\Users\MyPC\Desktop\GUI\ngspice\bin\test_circuit.circ")
    os.system(r"quit")

虽然调用上述函数可以完美地模拟和保存部分,但我无法退出,因为 ngspice 持有执行。有没有干净地退出ngspice?我不想每次都在 ngspice 命令窗口中手动输入 quit 或杀死它,因为模拟时间是可变的。

【问题讨论】:

    标签: python os.system pspice


    【解决方案1】:

    所以我找到了使用控制循环系统地退出 ngspice 的方法。在 test_circuit.circ 文件中,我在 .control 部分添加了退出语句,就是这样!

    .control 
    set filetype=ascii
    run 
    wrdata temp_file abs(v(A_1)-v(B_1)) 
    quit
    .endc
    

    【讨论】:

      猜你喜欢
      • 2019-01-25
      • 1970-01-01
      • 2023-03-12
      • 1970-01-01
      • 2011-12-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多