Site Search

Let's use LTspice - let's automatically run multiple simulations with a batch file!

When using LTspice in practice, does the simulation time become abnormally long?

In such cases, you might think, "It would be easier if we could automatically run simulations of different circuits in the middle of the night."

 

This time, I will introduce a method to automatically run multiple circuit simulations using the command prompt as a method to eliminate such troubles.

 

If you are just starting LTspice, we recommend that you look at the "basics" from the list below.

Let's use LTspice series list is here


Also, if you would like to see a video on how to write a basic circuit and how to execute it, there is an on-demand seminar that does not require you to enter personal information, so please take a look if you are interested. Detailed information about the seminar is also provided to those who fill in the questionnaire.

LTspice On-Demand Seminar - Function check with RC circuit -

 

Precautions before execution

LTspice_バッチファイルで複数のシミュレーションを自動実行_コントロールパネル_Automatically delete .raw files
Figure 1: Automatically delete .raw files[*] in Control Panel

If you leave the data after running the simulation, the hard disk capacity will be squeezed, so I think that there are many cases where the result file is automatically deleted after the simulation is finished. If you run a simulation using the command prompt with that setting, all the simulation results will disappear.

 

Therefore, when executing the simulation using the method explained here, uncheck "Automatically delete .raw files[*]" in the control panel in order to keep the simulation results.

1. Using Command Prompt

Before creating a batch file and running multiple circuit simulations, let's make sure that we can run LTspice simulations from the command prompt.

 

Open a command prompt and cd C:\Program Files\LTC\LTspiceXVII to move to the directory "\Program Files\LTC\LTspiceXVII" where the LTSPICE exe file is located.

LTspice_バッチファイルで複数のシミュレーションを自動実行_実行ファイルのあるディレクトリーに変更
Figure 2: Change to the directory with the LTspice executable

2. Netlist generation

Generate a netlist from a circuit file (.asc). A netlist is generated by executing XVIIx64.exe -netlist "file directory" on the command prompt (Figure 3). file directory specifies the folder that contains the circuit files to run.

 

This time, I will use the JIG file of the LDO product called LT1117 prepared by LTspice.

 

On the command prompt, specify C:\Users\username\Documents\LTspiceXVII\examples\jigs\1117.asc and execute. Then, a netlist will be generated in the same folder containing the schematic file (Fig. 4).

 

For how to use the files prepared in the JIG folder, please refer to the article "Easy! How to draw a circuit diagram in 5 steps".

LTspice_バッチファイルで複数のシミュレーションを自動実行_ネットリストの生成
Figure 3: Netlist generation

Confirm that a netlist called 1117.net is generated in the folder containing the circuit files (Figure 4).

LTspice_バッチファイルで複数のシミュレーションを自動実行_ネットリストの確認
Figure 4: Check netlist

3. Run the simulation

Now try running the simulation using the netlist (.net).

 

By executing XVIIx64.exe -b C:\Users\username\Documents\LTspiceXVII\examples\jigs\1117.net on the command prompt, the simulation result (waveform file) 1117.raw is generated.

LTspice_バッチファイルで複数のシミュレーションを自動実行_シミュレーションの実行
Figure 5: Running the simulation

Waveform data called 1117.raw is output as follows.

LTspice_バッチファイルで複数のシミュレーションを自動実行_シミュレーション結果(波形データファイル)
Figure 6: Simulation results (waveform data file)

4. Confirmation of simulation results (waveform)

Double-click the 1117.raw file to open it with LTspice.

Then select View Visible Traces from the toolbar to open the Select Visible Waveforms menu.

LTspice_バッチファイルで複数のシミュレーションを自動実行_シミュレーション結果の表示方法
Figure 7: How to display simulation results

In this window, select the node whose waveform you want to see. Figure 10 is the circuit diagram of the simulation we ran this time. I want to check the output waveform, so I check the number of the OUT node. . When I checked with the JIG circuit file, V(n002) corresponds.

Be careful because you can't know the number of the node of the OUT pin in advance.

 

It is convenient to label the nodes before running the simulation so that you can easily identify the node whose waveform you want to check.

 

(Reference) Let's use LTspice - clean circuit diagram with "Label Net"

LTspice_バッチファイルで複数のシミュレーションを自動実行_LT1117の回路図
Figure 8: LT1117 schematic

From the selection list in Figure 9, select V(n002) and load current (I1) that correspond to the OUT node.

LTspice_バッチファイルで複数のシミュレーションを自動実行_波形の選択
Figure 9: Waveform selection

The resulting waveform looks like this (Figure 10). I(I1) is the load current change waveform, and V(n002) is the OUT waveform.

It can be confirmed that the output voltage VOUT fluctuates due to the fluctuation of the load current I1.

LTspice_バッチファイルで複数のシミュレーションを自動実行_シミュレーション結果
Figure 10: Simulation results

Batch processing

Processing 1 to 5 is the method of manually executing a simulation using commands on the command prompt.

By creating this command processing in text and making it a bat file, it is possible to automatically execute multiple simulations in succession. This is useful when processing multiple time-consuming simulations while you sleep.

 

As a reference, I made a sample file for batch processing JIG files of LT1117 and LT1118.

Download the sample file below and try it out.

 

The downloaded ZIP file contains a text file called LTspice.txt.

Change the "username" part of the directory in the text to the folder name on your PC.

If you want to run it, change the extension txt to bat and run it.

 

* When simulating for a long time, please note that the simulation will stop when the PC goes to sleep.

At the end

If you haven't used LTspice yet, please download LTspice from the link below!

Please try once.

Download LTspice here


We also hold regular LTspice seminars for beginners. You can learn the basic operation of LTspice, so please participate.

Click here for LTspice seminar information

Click here for recommended articles/materials

List of articles: Let's use LTspice Series

LTspice FAQ:  FAQ list

List of technical articles:  technical articles

Manufacturer introduction page:  Analog Devices, Inc.  

Click here for recommended seminars/workshops

Click here for analog technology seminar information

Inquiry

If you have any questions regarding this article, please contact us below.

Analog Devices Manufacturer Information Top

If you want to return to Analog Devices Manufacturer Information Top, please click below.