SimRunner

class PyLTSpice.sim.sim_runner.SimRunner(*, simulator=None, parallel_sims=4, timeout=600.0, verbose=False, output_folder=None)[source]

Bases: SimRunner

The SimCommander class implements all the methods required for launching batches of LTSpice simulations. It takes a parameter the path to the LTSpice .asc file to be simulated, or directly the .net file. If an .asc file is given, the class will try to generate the respective .net file by calling LTspice with the –netlist option :raises FileNotFoundError: When the file is not found /!This will be changed

Parameters:
  • parallel_sims (int, optional) – Defines the number of parallel simulations that can be executed at the same time. Ideally this number should be aligned to the number of CPUs (processor cores) available on the machine.

  • timeout (float, optional) – Timeout parameter as specified on the os subprocess.run() function. Default is 600 seconds, i.e. 10 minutes. For no timeout, set to None.

  • verbose (bool, optional) – If True, it enables a richer printout of the program execution.

  • output_folder (str) – specifying which directory shall be used for simulation files (raw and log files).

  • output_folder – str

  • simulator (str or Simulator, optional) – Forcing a given simulator executable.

create_netlist(asc_file, cmd_line_args=None)[source]

Creates a .net from an .asc using the LTSpice -netlist command line

class spicelib.sim.run_task.RunTask(simulator, runno, netlist_file, callback=None, callback_args=None, switches=None, timeout=None, verbose=False, cwd=None, callback_on_error=False, exe_log=False)[source]

This is an internal Class and should not be used directly by the User.

get_results()[source]

Returns the simulation outputs if the simulation and callback function has already finished. If the simulation is not finished, it simply returns None. If no callback function is defined, then it returns a tuple with (raw_file, log_file). If a callback function is defined, it returns whatever the callback function is returning, unless the simulation failed, and callback_on_error is False (default), in which case it returns None.

Returns:

Tuple with the path to the raw file and the path to the log file

Return type:

Any | tuple[str, str] | None

run()[source]

Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.

wait_results()[source]

Waits for the completion of the task and returns a tuple with the raw and log files.

Returns:

Tuple with the path to the raw file and the path to the log file. See get_results() for more details.

Return type:

Any | tuple[str, str]