Python Forum

Full Version: Connection LTspice-Python with PyLTSpice
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everybody,

Does anyone have experience with integrating LTspice circuitry into Python, i.e. primarily .asc files?

Does anyone happen to know what's wrong with the following code? For example, how can you output the voltage at the output of the circuit?

import pyltspice
circuit = pyltspice.Circuit.from_file("test12Vtransistor.asc")
circuit.set_analysis_type("tran")
circuit.set_time_range(0, 10ms) # 10ms Simulationsdauer
circuit.set_step_size(1ms) # 1ms Schrittweite
circuit.simulate()
time = circuit.get_time()

import matplotlib.pyplot as plt

plt.plot(time, voltage)
plt.xlabel("Zeit (ms)")
plt.ylabel("Spannung (V)")
plt.title("Simulationsergebnisse")
plt.grid(True)
plt.show()
I am a beginner with Python and until now I have many problems to understand how to realize that.

Thanks for your help!!!