如何从 pyspice 模型中绘制电路图?

问题描述 投票:0回答:1

有谁知道如何将 pyspice 模型传递给绘制电路图的函数?这将帮助我检查我的设计是否正确。

我打印了模型,但这不是很有帮助,而且我无法让它与 schemdraw 一起使用。

python schemdraw pyspice
1个回答
0
投票

您可以尝试像我的示例一样来生成以下电路:

enter image description here

代码:

import schemdraw
import schemdraw.elements as elm
from PySpice.Spice.Netlist import Circuit
from PySpice.Unit import *

circuit = Circuit('Example Circuit')
circuit.R(1, '1', '2', 1@u_kΩ)
circuit.C(1, '2', '0', 1@u_uF)
circuit.V(1, '1', '0', 5@u_V)

# Function to draw the circuit
def draw_circuit(circuit):
    with schemdraw.Drawing() as d:
        for element in circuit.elements:
            if element.name.startswith('R'):
                d += elm.Resistor().label(element.name)
            elif element.name.startswith('C'):
                d += elm.Capacitor().label(element.name)
            elif element.name.startswith('V'):
                d += elm.SourceV().label(element.name)
        d.draw()

draw_circuit(circuit)

关于套餐:

pip install schemdraw
pip install pyspice
© www.soinside.com 2019 - 2024. All rights reserved.