Automating SPIS (6.2.4) using python scripts

I’m trying to create a script to automate a bunch of simulations with changing parameters (electron/ion density & temp). When trying to find the correct classes to call to, I run into some problems:

Classes defined by the documentation (through SpisNUM API documentation) seem to be for older versions.

Certain libraries when trying to use a specific class (for example calling the GlobalParameter class through Spis.Top.Default) cannot be found. Many of the libraries that the documentation suggests don’t seem to be in my current SPIS folder.

For the later versions of SPIS, what libraries/packages do I call to and where can that info be found? If anyone can just point me to the global parameters class as well that’d be much appreciated. I also read through the git repositories for compiling SPIS, would compiling SPIS altogether resolve this issue?

Hi Joseph,

Regarding your questions:

  • Recompiling SPIS locally will not resolve the issues you are seeing with missing or outdated classes.

  • Under Linux, a Jython script can be launched with SPIS using the following command:

    ./Spis.sh -b mySpisTask.py
    
  • You can find examples showing how to build and run multiple simulations in batch mode using different input parameter sets in the following directory:

    SPIS/resources/scripts

    These scripts illustrate the recommended way to construct simulations programmatically, rather than directly calling low-level classes such as GlobalParameter.

  • I would recommand to use SPIS 6.2.6. As mentioned in the SPIS 6.2.6 Changelog:

    • “Uniformize inputs for Jython scripts using environment variables”
    • “Fix issue with Jython scripts and groups loading.”
  • To run a simulation with a specific set of global parameters, the workflow is generally:

    1. First generate the file in which all global parameters are defined (or groups or electrical circuit or other input files).

    2. Then build the SPIS simulation using this generated global-parameter file as input.

  • One important point to be aware of when using Jython scripts: all SPIS simulations are executed within the same JVM. In some cases, objects from completed simulations may remain in memory and not be freed by the garbage collector. As a result, memory usage can increase as more simulations are launched in the same process.

  • Because of this, the most robust approach for parameter sweeps is usually:

    1. Build all input files, each set corresponding to a different set of parameters.

    2. Use a Jython script (with SPIS) or your own script (Python, shell, …) to generate all the required SPIS simulations.

    3. Use a separate bash script to launch these simulations, either sequentially or in parallel, depending on your needs and hardware resources.

I hope this clarifies how to proceed with scripting and batch simulations in SPIS. If needed, we can also provide dedicated support for SPIS through our SpaceSuite offering: www.space-suite.com

Best,

Benjamin

This helps a ton. Thank you.

To clarify further, does this effectively mean I have to create a new project for each simulation? I intend to keep everything else the same (circuit, 3D model, groups etc) but just change certain parameter values.

I have a couple other questions if you could help. If I wanted to follow through with using my own script, where can I find the sources for the classes? I noticed that not all of the .jar files that are in some of the pre-made scripts are actually within the SPIS program folder that I downloaded. Do the scripts pull from on-line sources?

Hi Joseph,

Yes, you have to create a new SPIS project (.spis) for each parameter value.

Hi Joseph,

I recommend to use the existing scripts defined below as example to build you own scripts, it will easy your work:

SPIS/resources/scripts

Nothing is downloaded by SPIS when a script is executed, the scripts use only classes defined in the jar files packaged with SPIS.