有谁知道如何将 pyspice 模型传递给绘制电路图的函数?这将帮助我检查我的设计是否正确。
我打印了模型,但这不是很有帮助,而且我无法让它与 schemdraw 一起使用。
您可以尝试像我的示例一样来生成以下电路:
代码:
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