¿ªÔÆÌåÓý


Re: Simulating Using PyLTSpice Takes Too Long

 

I have made contact with PyLTspice developer, and he pointed out that It could not be sped up further.
?
Thank you for your attention


Re: Simulating Using PyLTSpice Takes Too Long

 

On Sat, Mar 29, 2025 at 05:35 PM, <davitkharshiladze26@...> wrote:
LTSpice generates .raw output files, noramlly.
Correct.

I am using PyLTSpice tp prepeare netlist before simulation. I am manually writing the netlist.
Hmm.? I see some confusion there.? Do you manually write the netlist, or does PyLTSpice write or alter the netlist?? Obviously, if PyLTSpice needs to add .NET commands, it must be writing a netlist file (perhaps after reading one without the .NET commands), so that could be one place where some delay gets added.

After simulation, I am gathering .raw files and reading info from them.
Do you mean that you manually gather and read the .raw files?? Or does PyLTSpice have a hand in doing that?

I also use PyLTSpice to directly run the simulation after the netlists are prepeared:
Got that.

LTC.run runs the simulator and LTC.wait_completion() waits for .raw generation to finish. ...
Hmm.? That sets off alarm bells in my head.? How does PyLTSpice actually wait for LTspice to finish generating the .raw file?? Does it periodically probe the .raw file, looking for some sort of signature indicating that it is finished?? Does it wait until no further writing happens to the .raw file for the last, I don't know, let's say 15 seconds?? Does it examine the .log file waiting for a completion signature, and then post-process the .raw file?? Does it wait for Windows to signal that the process it was asked to run (running LTspice) has finished?
?
Any of these things MIGHT introduce delays, anywhere from milliseconds to dozens of seconds, depending on what it does and how.
?
The runtime of these 2 functions are approximately 1 second, which is way too much for my purposes.
What 2 functions are you talking about?
?
How much time is acceptable?

I feel like normal LTSpice simulation takes about the same time, though, as I mentioned, it is harder to measure
Now this is where I get really confused.
?
I think you're saying that it takes the same amount of time for LTspice to run a simulation, as it takes for PyLTSpice to run the same simulation.
?
Is LTspice being run in so-called "batch" mode (with the "-b" switch), so that it omits all the screen graphics?? If you aren't doing that, then perhaps the extra overhead happens when LTspice takes the time to open a schematic window and a plot window and scale its axes.? You don't need it to do that if you plan to only post-process the .raw file's data.
?
Andy
?


Re: Simulating Using PyLTSpice Takes Too Long

 

1 second is too much for my purposes, and runtime is 1 second whether I use LTspice or PyLTspice? to run the simulaiton


Re: PTC model with internal temperature rise

 

On Fri, Mar 21, 2025 at 01:48 PM, <pilou@...> wrote:
Sorry I'll uptload it again later.
It's OK now, I just uploaded it.


Re: Simulating Using PyLTSpice Takes Too Long

 

Sorry, I see that the author of PyLTSpice does not know how to spell "LTspice".
?
LTspice has no capital "s".? It is spelled "LTspice".
?
PyLTSpice has a capital "S".
?
Humph.
?
Andy
?


Re: Simulating Using PyLTSpice Takes Too Long

 

Help? me understand the problem.
?
<davitkharshiladze26@...> wrote:
... However, simulation takes too much time. It takes 1 second for the simulation to complete. ...
Is 1 second too much time and that is what you want to reduce?
?
Or is 1 second small, and adding PyLTspice causes the total time to be much greater than 1 second?
?
Andy
?


Re: Conductance Negative

 

On Sat, Mar 29, 2025 at 05:41 PM, alan victor wrote:
Use the educational examples, oscillators, Colpits and remove the resonating inductor leaving the active device and passive feedback?
elements in place. ...
I might be wrong, but I think alan is referring to one of the example schematics that installs on your computer's disk when you install LTspice.
?
...\examples\Educational\Colpitts.asc
?
Andy
?


Re: Conductance Negative

 

On Fri, Mar 28, 2025 at 11:53 AM, <sebastian.herrera@...> wrote:
Dear all, I am trying to simulate a circuit with negative conductance using transistors and passive components. Does anyone have a circuit for this?
Use the educational examples, oscillators, Colpits and remove the resonating inductor leaving the active device and passive feedback?
elements in place. Do a scattering parameter operation and note the modulus of S11 is > unity over the range of potential frequency
of operation. This yields negative conductance. Note there is a nice peak in negative G value in the 1-10 MHz range and extends out to ~ 40 MHz.?


Re: Simulating Using PyLTSpice Takes Too Long

 

LTSpice generates .raw output files, noramlly.
?
I am using PyLTSpice tp prepeare netlist before simulation. I am manually writing the netlist.
After simulation, I am gathering .raw files and reading info from them.
I also use PyLTSpice to directly run the simulation after the netlists are prepeared:

? ? ? ? t1?=?time.time()
? ? ? ??LTC.run(netlist=netlist_filename)
? ? ? ??LTC.wait_completion()
? ? ? ??print(f"{t1?-?time.time()}?- Simrun")
LTC.run runs the simulator and LTC.wait_completion() waits for .raw generation to finish. Afterwards i can read these files for my desired outputs.
The runtime of these 2 functions are approximately 1 second, which is way too much for my purposes.
I feel like normal LTSpice simulation takes about the same time, though, as I mentioned, it is harder to measure


Re: Simulating Using PyLTSpice Takes Too Long

 

So -- what files does PyLTspice need to write and read?
?
I still think (from your description) that this is the bottleneck.
?
Andy
?


Re: Simulating Using PyLTSpice Takes Too Long

 

No, I am not using .MEAS commands.
?
I tried using some mechanisms that reduced filesize for .raw files, but results remained the same.


Re: Simulating Using PyLTSpice Takes Too Long

 

As far as I know, file reading and writing are part of the reported simulation time.
?
You might affect that by controlling where it accesses those files, and how big they can be.
?
Andy
?


Re: Simulating Using PyLTSpice Takes Too Long

 

Wait - are you using .measure commands?? Is that where you see things slowing down?
?
.MEAS commands are indeed processed after the simulation is over.
?
Andy


Re: Simulating Using PyLTSpice Takes Too Long

 

Unfortunately, I can not use .STEP command.?
My main problem is finding multi-port s-parameters of a given circuit. LTSpice only supports 2-port s-parameters. To measure 4-port s-parameters I need to run simulation several times (6 times to be exact), where I change the port locations on each iteration. This requires me to slightly modify the netlist, meaning that I am running practically new simulation each time.
?
Even when I run simulaiton using LTSpice it still takes approximately 1 second, thought, it is harder for me to measure, therefore, I feel the problem is within the simulator itself. I feel like the simulator needs time for initializing, file writting and so on. I have not found a way to disable any additional protocols.
?
Thank you for your responses?


Re: Simulating Using PyLTSpice Takes Too Long

 

Can you re-do your sims using .STEP ?? Thus avoiding PyLTspice?
?
Andy


Re: Simulating Using PyLTSpice Takes Too Long

 

¿ªÔÆÌåÓý

I made the schematic in LTspice and it runs very fast. The netlist is:

* C:\Program Files\ADI\LTspice\Draft1.asc
V1 N001 0 AC 1 0
L1 N002 N001 10?
C1 N002 0 1p
R1 N002 0 50k
.ac dec 150 10meg 100G
.backanno
.end

The .ASC is just temporarily stored with that path, because I have not Saved it.

On 2025-03-29 20:45, davitkharshiladze26 via groups.io wrote:
eetch00,
?
I obtained this from viewing LTSpice netlist.
Nevertheless, I tried changing it after your comment and results remained the same
--
OOO - Own Opinions only If something is true: * as far as we know - it's science *for certain - it's mathematics *unquestionably - it's religion

Virus-free.


Re: Simulating Using PyLTSpice Takes Too Long

 

I have no familiarity with PyLTspice.? But you say most of the time is spent doing something other than the LTspice simulation itself.? Which means the cause is something other than LTspice.
?
Maybe there's another way to automate your sims which doesn't use this particular slow Python code, which seems to be the bottleneck.
?
.AC simulations can be quite fast and there's very little dependency on the sweep parameters.? That's because .AC analysis is 100% linear, once the operating point is found.? The sweep requires no iterations and no convergence issues.? It's fast.
?
Contrary to what eT wrote, I think your netlist is fine and without problems.
?
Andy
?


Re: Simulating Using PyLTSpice Takes Too Long

 

eetch00,
?
I obtained this from viewing LTSpice netlist.
Nevertheless, I tried changing it after your comment and results remained the same


Re: Simulating Using PyLTSpice Takes Too Long

 

On Sat, Mar 29, 2025 at 12:42 PM, <davitkharshiladze26@...> wrote:
The circuit may have some unreasonable problems, however, I am not plotting anything, nor am I trying to obtain any meaningful data from this circuit. This is a dummy circuit that represents the problem that my original meaningful circuit had. I can not share my original circuit.
?
Changing frequency sweep keeps the simulation runtime the same. Changing the format of stimulus does not make any change either.
?
You can confirm the netlist format by simulating it directly in LTspice without using python.
It won't run correctly formatted the way you've shown.
See my previous post.
?


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")