NUNO BRUM
  • About Me
  • Sheet Comparator
  • PyLTSpice
  • ResistorSolver
  • Blog
  • Help

PyLTSpice - LTSpice Automation Tools with python (Current Version 3.0)

Install

Install directly from command line
pip install PyLTSpice

PyLTSpice is hosted in PyPi
https://pypi.org/project/PyLTSpice/

and in github.org
https://github.com/nunobrum/PyLTSpice.git​
Donations serve to support costs with website hosting  and with financing the development of other tools.  The excess will be sent to non profit  and community organisations. 
Supported Organisations:
  • https://pencilsofpromise.org
  • https://www.khanacademy.org/donate


  • sim_batch.py This is a script to launch LTSpice Simulations. This is useful because:
    • Can overcome the limitation of only stepping 3 parameters
    • Different types of simulations .TRAN .AC .NOISE can be run in a single batch
    • The RAW Files are smaller and easier to treat
    • When used with the LTSpiceRaw_Reader.py and LTSteps.py, validattion of the circuit can be done automatically.
    • Different models can be simulation in a single batch. The principle of operation is the following :
      1. Add to the Spice circuit a .INC sim_settings.lib . In this include simulation directives are written by the script per each simulation call.
      2. Use the python script to update the simulation directives and call LTSpice to run the simulation in command line.
      3. When the simulation is complete, the simulation results are renamed according to user guidance.
  • raw_reader.py ​ A pure python implementation of an LTSpice RAW file reader.
The reader returns a class containing all the traces read from the RAW File. In case there there stepped data detected, it will try to open the simulation LOG file and read the stepping information.

​ Traces are accessible by the method "get_trace(trace_ref)" where trace_ref is either the name of the net on the LTSPice Simulation. Normally trace references are stored with the format V(<node_name>) for voltages or I(device_reference) for currents. For example V(n001) or I(R1) or Ib(Q1).
For checking steps in simulations, the method get_steps() should be used. In case there are no steps in the simulation, the class will return a single element list.

NOTE: This module tries to import the numpy if exists on the system. If it finds numpy all data is later provided as an array. If not it will use a standard list of floats. 

Below there is an example of the  class usage.
​
LT = RawRead("Draft1.raw")
IR1 = LT.get_trace("I(R1)")
x = LT.get_trace(0)  # Zero is always the X axis
steps = LT.get_steps()
for step in range(len(steps)):
    # print(steps[step])
    plt.plot(x.get_wave(step), IR1.get_wave(step), label=steps[step])

plt.legend() # order a legend.
plt.show()

  • LTSteps.py An utility that extracts from LTSpice output files data, and formats it for import in a spreadsheet,s uch like Excel or Calc.
  • Histogram.py Uses numpy and matplotlib to create an histogram and calculate the sigma deviations. This is useful for Monte-Carlo analysis.

Thanks for your visit

Email

me@nunobrum.com

  • About Me
  • Sheet Comparator
  • PyLTSpice
  • ResistorSolver
  • Blog
  • Help