Running PySSC

There are two ways to run simulations within this project: using PySAM. (recommended) and using PySSC (ideally for debugging).

Instead of calling the NE2 modules, we call instead use a single class called PySSCWrapper found in neup-ies/simulations/util.

Note

This is not set up for using with Pyomo optimization. You can, however, run a simulation with dispatch optimization using the NE2-PySAM script which will save a dispatch target time series. PySSC runs can then automatically load those dispatch target files (if the JSON inputs are the same!) and use them as a vector input.

A number of example scripts for running a simulation can be found under neup-ies/simulations/scripts/PySSC_scripts. Notably, run_PySSCWrap_model1 is the cleanest.

Here is a general outline of how to run a simulation.

  1. Build SSC in either export or debug mode. Instructions found here:.

  2. PYTHONPATH: Make sure the neup-ies/simulations/ directory is in your Python path, either in your terminal or whatever IDE you are using.

  3. Optional: Print PID: To help in setting up mixed-mode debugging, you can print out the process ID number so you can attach a C++ IDE to the current process:

    pid = os.getpid()
    print("PID = ", pid)
    
  4. Initialize the PySSCWrapper object

    pw = PySSCWrapper()
    

    Note that there are two input parameters you can specify:

    • json_name (str) – name of JSON script with input data for module (just the name, don’t specify directory)

      Note

      JSON scripts can be found neup-ies/simulations/json. For more information on the structure of the JSON scripts, see this guide:.

    • is_debug (bool) – boolean, if True calls on SSC through debug .so library file, else chooses the export library .so file

  5. Run Simulation:

    pw.run_sim()
    

    Note that there is one input parameter you can specify:

    • run_dispatch_targets (bool) – if True, loads dispatch target time series from saved hash file whose name matches JSON inputs (only if it exists).

Mixed-Mode Debugging

For a detailed guide on setting up mixed-mode debugging (between Python and C++) check here. I also wrote a separate one for Eclipse IDE that is also in that wiki.

Mixed-mode debugging would be possible in Microsoft Visual Studio Code but have not personally figured that out yet.