¿ªÔÆÌåÓý

Re: Simulating Using PyLTSpice Takes Too Long


 

try the developer.?






On Sat, Mar 29, 2025 at 3:01 PM, davitkharshiladze26 via groups.io
<davitkharshiladze26@...> wrote:
Hello Everyone,
?
I am trying to simulate very simple circuit using PyLTSpice. However, simulation takes too much time. It takes 1 second for the simulation to complete. Even when I increased the complexity of the circuit, time taken for simulation still stays approximately the same. I increased-decreased number of freuqncy points in my ac analysis, this had little to no effect on simulation runtime.
?
I feel like most of the simulation time is spent reading-writing files. Does anybody has any suggestions that can be beneficial to speeding up the process?
?
Currently, I am using LTSpice simulator, as seen on the third line.
?
?
import time
from PyLTSpice import SimRunner
from spicelib.simulators.ltspice_simulator import LTspice


# Create the netlist file (simple_lc.cir)
netlist_content = """* Simple LC Resonant Circuit
V1 N001 0 AC 1
L1 N001 N002 10uH
C1 N002 0 1pF
R1 N002 0 50
.ac lin 1500 40Meg 60g
.save V(N002)
.end
"""

# Save netlist
netlist_filename = "simple_lc.cir"
with open(netlist_filename, "w") as f:
? ? f.write(netlist_content)

LTC = SimRunner(output_folder='/temp', simulator=LTspice) # init simulation runner

for i in range(1,10): # iterate ove reverything
? ? ? ? t1 = time.time()
? ? ? ? LTC.run(netlist=netlist_filename)
? ? ? ? LTC.wait_completion()
? ? ? ? print(f"{t1 - time.time()} - Simrun")

Join [email protected] to automatically receive all group messages.