Python Forum
Connection LTspice-Python with PyLTSpice - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Connection LTspice-Python with PyLTSpice (/thread-41553.html)



Connection LTspice-Python with PyLTSpice - bartel90 - Feb-05-2024

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!!!