send commands when LTspice is running in batch mode


 

hello,
when LTspice was launched in batch mode (command line just with the -b option), how to send (ex : with a python script) an additional command to LTspice for the execution of different netlist files (.net) or schema files (.asc) one after the other ?
I would like LTspice not to be stopped and then restarted for each requested run. LTspice should stay in the background keeping the instance alive between calls.
In advance, thank you for your answers.


 

LTspice needs to have all of the files in place already when it begins each Batch simulation.
 
Andy
 


 

On 07/11/2024 10:10, Christophe wrote:
when LTspice was launched in batch mode (command line just with the -b option), how to send (ex : with a python script) an additional command to LTspice for the execution of different netlist files (.net) or schema files (.asc) one after the other ?
I would like LTspice not to be stopped and then restarted for each requested run. LTspice should stay in the background keeping the instance alive between calls.
In advance, thank you for your answers.
I don't believe you can do that. The whole idea of doing something in batch mode, is that it creates a separate job each time. You can have multiple jobs running at a time, but they can't communicate.

It's a long time since I did anything with LTspice and Python. Are you using Python threads? I seem to remember that you can keep threads alive, although the called LTspice process runs and stops after the .raw file is written, so you have to call a new one for each analysis.

--
Regards,
Tony



 

THANKS. I understand that this path is apparently not the right one. I will rephrase my problem and my question more harshly in the hope that there is a solution! I have to perform around 50 simulations with different netlists. For now, I'm launching them one after the other. Between the total time for 1 simulation, approximately 0.6 seconds, and the time displayed in the log file of approximately 15 ms, the difference is enormous. I don't know what the time gap is due to. Do you have an idea (excluding parallelization) to reduce the total time by 0.6s to get closer to 15ms?
In advance, thank you.


 

Do you need each analysis to finish before the next one starts, i.e. do the netlists all exist independently at the start, or are you reading the logfile for .meas results to use to formulate the next netlist, like if you were doing a gradient optimiser, for example? Or may be you're reading the .raw file instead?

If the netlists are independent, you can run several instances of LTspice in parallel. How many depends on your computer. I seem to remember I could run at least the same number in parallel as there were cores. This work was done in 2010-11 with a much less powerful machine than I have now, and my memory is a bit hazy now.

--
Regards,
Tony

On 07/11/2024 15:55, Christophe wrote:

THANKS. I understand that this path is apparently not the right one. I will rephrase my problem and my question more harshly in the hope that there is a solution! I have to perform around 50 simulations with different netlists. For now, I'm launching them one after the other. Between the total time for 1 simulation, approximately 0.6 seconds, and the time displayed in the log file of approximately 15 ms, the difference is enormous. I don't know what the time gap is due to. Do you have an idea (excluding parallelization) to reduce the total time by 0.6s to get closer to 15ms?
In advance, thank you.


 

Yes, I need a simulation to be completed before building the netlist for the next simulation. I use .raw to extract the information necessary for my processing. In my case, parallel simulation does not appear relevant for the moment. 
I think that with each call there is a time for "loading" (?) of the program and initialization (?) which is long while the simulation is very fast (in my case). I wanted to know if there was a way to reduce this loading and initialization time by avoiding stopping and restarting the simulator at each new request in batch mode.
THANKS.


 

On 08/11/2024 09:43, Christophe wrote:
Yes, I need a simulation to be completed before building the netlist for the next simulation. I use .raw to extract the information necessary for my processing. In my case, parallel simulation does not appear relevant for the moment. 
I think that with each call there is a time for "loading" (?) of the program and initialization (?) which is long while the simulation is very fast (in my case). I wanted to know if there was a way to reduce this loading and initialization time by avoiding stopping and restarting the simulator at each new request in batch mode.
I had a quick look at batch processing with V24.0.12 and a very simple netlist, which included one .MEAS directive. Now I use Linux, so startup is significantly slower than in Windows because the Wine infrastructure has to be loaded and unloaded each time.

First interesting observation was that the actual reported analysis time in the logfile was quite a bit quicker in batch mode than GUI mode: 5-10ms compared to 30-50ms. However, this was largely irrelevant as invoking and running the batch process took 4 seconds. Running the batch process 10 times sequentially, brought this down to 2.7s per run, and at 30 times to 2.5s per run.

I found it was possible to run 30 LTspice processes in parallel without any slowdown, but obviously this doesn't help your current requirement.

I don't think it is possible to keep the batch process loaded, like the old DOS TSR (terminate and stay resident programs). There would probably be good security reasons to make this impossible.

Perhaps by reformulating your problem, you can make some use of parallelisation to speed up your application.

For situations like this, it would be helpful if it were possible to run external processes from LTspice. That would open up a while range of possibilities.

--
Regards,
Tony



 

On 08/11/2024 13:06, Tony Casey wrote:
That would open up a while range of possibilities.
--> That would open up a whole range of possibilities.


 

Yes, I agree. I come to the same conclusion. I need to parallelize the treatment!
Thank you again for this exchange.