simulations.modules package

Submodules

simulations.modules.DualIndirectTES module

Created on Fri Apr 15 16:28:05 2022

@author: gabrielsoto

class simulations.modules.DualIndirectTES.DualIndirectTES(plant_name='nuclear_mspt_indirect_tes', json_name='model2', dual=True, direct=False, **kwargs)[source]

Bases: modules.SolarTES.SolarTES

The DualPlantTES class intializes, updates, and runs SSC simulations through PySAM, specifically for the SSC nuclear_mspt_tes module.

This is meant to simulate the intermediate cycle where the Nuclear and Solar plants are both directly connected to the storage tank - power cycle loop. That is, the Nuclear and Solar Power Tower heat parallel mass flows of molten salt via respective heat exchangers. Each molten salt mass flow then routes directly to the hot storage tank where it can be dispatched out to the power cycle.

__init__(plant_name='nuclear_mspt_indirect_tes', json_name='model2', dual=True, direct=False, **kwargs)[source]

Initializes the DualPlantTES module

Inputs:

plant_name (str) : name of SSC module to run json_name (str) : name of JSON script with input data for module is_dispatch (bool) : boolean, if True runs Pyomo dispatch optimization

create_dispatch_params(Plant)[source]

Populating a dictionary with dispatch parameters before optimization

Note

self.is_dispatch == True (Called within simulation)

This method is creates the Dispatch Parameter dictionary that will be populated with static inputs from SSC_dict as well as initial conditions for Dispatch optimization. The initial conditions are continuously updated if simulation is segmented.

Parameters

Plant (obj) – original PySAM Plant module

Returns

wrapper object for the class that creates dispatch parameters

Return type

dispatch_wrap (obj)

create_dispatch_wrapper(PySAM_dict)[source]

Creating a wrapper object for calling a class that creates dispatch parameters

** self.is_dispatch == True (Called in __init__ of NE2 module)

This method creates an object whose class ultimately calculates and creates parameters for Dispatch optimization. The reason this class exists separately is that it gets overlaoded based on the PySAM module we are running. Depending on the PySAM module, this method calls on a different Dispatch Parameter class that is specific to the module.

Inputs:

PySAM_dict (dict) : dictionary of PySAM inputs from a script in /json directory

Outputs:

dispatch_wrap (obj) : wrapper object for the class that creates dispatch parameters

initialize_arrays()[source]

Initializing empty arrays to log SSC outputs after segment simulations

This method creates empty arrays where SSC outputs will be written to. Also creates a list of str names for logged simulation outputs.

update_Plant_after_Pyomo(Plant, pre_dispatch_run=False)[source]

Update SSC Plant inputs with Pyomo optimization outputs from current segment simulation

Note

self.run_loop == True (can be called outside loop) self.is_dispatch == True

This method uses the optimization results from Pyomo and ensures that the next SSC segment uses them throughout the corresponding SSC Horizon. SSC normally takes single values for initial conditions (for the first hour of the SSC Horizon), but it can also take in an array of values for each step in the SSC Horizon. These are called “dispatch_targets”. Steps are: (1) extract solutions from Pyomo over the Pyomo Horizon, (2) keep the solutions for the shorter SSC Horizon and (3) save these “dispatch target” inputs to the Plant object for the next SSC simulation segment.

Parameters
  • Plant (obj) – original PySAM Plant module to be updated

  • pre_dispatch_run (bool) – are we updating the Plant for a pre- or post- dispatch run. Recall that we only log post-dispatch Plant runs

Returns

updated PySAM Plant module

Return type

Plant (obj)

update_Plant_after_SSC()[source]

Update SSC Plant inputs with SSC outputs from previous segment simulation

** self.run_loop == True

This method uses the SSC end results from the previous simulation segment and sets them as the initial conditions for the next SSC segment. As a small note: some outputs are arrays that span the full year, however the only relevant parts are the first indeces corresponding to the SSC Horizon. All other values are typically 0.

update_Pyomo_after_SSC(Plant, params)[source]

Update Pyomo inputs with SSC outputs from previous segment simulation

Note

self.run_loop == True self.is_dispatch == True

This method uses the SSC end results from the previous simulation segment and uses them to update the existing Dispatch parameter dictionary that is ultimately sent to Pyomo. Essentially just updates the initial conditions of the Dispatch parameter dictionary.

Parameters
  • Plant (obj) – original PySAM Plant module

  • params (dict) – dictionary of Pyomo dispatch parameters

Returns

updated dictionary of Pyomo dispatch parameters

Return type

params (dict)

simulations.modules.DualPlantTES module

Created on Tue Nov 2 14:03:51 2021

@author: gabrielsoto

class simulations.modules.DualPlantTES.DualPlantTES(plant_name='nuclear_mspt_tes', json_name='model2', dual=True, **kwargs)[source]

Bases: modules.SolarTES.SolarTES

The DualPlantTES class intializes, updates, and runs SSC simulations through PySAM, specifically for the SSC nuclear_mspt_tes module.

This is meant to simulate the intermediate cycle where the Nuclear and Solar plants are both directly connected to the storage tank - power cycle loop. That is, the Nuclear and Solar Power Tower heat parallel mass flows of molten salt via respective heat exchangers. Each molten salt mass flow then routes directly to the hot storage tank where it can be dispatched out to the power cycle.

__init__(plant_name='nuclear_mspt_tes', json_name='model2', dual=True, **kwargs)[source]

Initializes the DualPlantTES module

Inputs:

plant_name (str) : name of SSC module to run json_name (str) : name of JSON script with input data for module is_dispatch (bool) : boolean, if True runs Pyomo dispatch optimization

create_dispatch_params(Plant)[source]

Populating a dictionary with dispatch parameters before optimization

Note

self.is_dispatch == True (Called within simulation)

This method is creates the Dispatch Parameter dictionary that will be populated with static inputs from SSC_dict as well as initial conditions for Dispatch optimization. The initial conditions are continuously updated if simulation is segmented.

Parameters

Plant (obj) – original PySAM Plant module

Returns

wrapper object for the class that creates dispatch parameters

Return type

dispatch_wrap (obj)

create_dispatch_wrapper(PySAM_dict)[source]

Creating a wrapper object for calling a class that creates dispatch parameters

** self.is_dispatch == True (Called in __init__ of NE2 module)

This method creates an object whose class ultimately calculates and creates parameters for Dispatch optimization. The reason this class exists separately is that it gets overlaoded based on the PySAM module we are running. Depending on the PySAM module, this method calls on a different Dispatch Parameter class that is specific to the module.

Inputs:

PySAM_dict (dict) : dictionary of PySAM inputs from a script in /json directory

Outputs:

dispatch_wrap (obj) : wrapper object for the class that creates dispatch parameters

initialize_arrays()[source]

Initializing empty arrays to log SSC outputs after segment simulations

This method creates empty arrays where SSC outputs will be written to. Also creates a list of str names for logged simulation outputs.

update_Plant_after_SSC()[source]

Update SSC Plant inputs with SSC outputs from previous segment simulation

** self.run_loop == True

This method uses the SSC end results from the previous simulation segment and sets them as the initial conditions for the next SSC segment. As a small note: some outputs are arrays that span the full year, however the only relevant parts are the first indeces corresponding to the SSC Horizon. All other values are typically 0.

update_Pyomo_after_SSC(Plant, params)[source]

Update Pyomo inputs with SSC outputs from previous segment simulation

Note

self.run_loop == True self.is_dispatch == True

This method uses the SSC end results from the previous simulation segment and uses them to update the existing Dispatch parameter dictionary that is ultimately sent to Pyomo. Essentially just updates the initial conditions of the Dispatch parameter dictionary.

Parameters
  • Plant (obj) – original PySAM Plant module

  • params (dict) – dictionary of Pyomo dispatch parameters

Returns

updated dictionary of Pyomo dispatch parameters

Return type

params (dict)

simulations.modules.GenericSSCModule module

Created on Thu Apr 8 13:40:22 2021

@author: gabrielsoto

class simulations.modules.GenericSSCModule.GenericSSCModule(plant_name='abstract', json_name='abstract', dual=False, direct=True, is_dispatch=False, dispatch_time_step=1, log_dispatch_targets=False, exec_debug=False, exec_timeout=10.0, **kwargs)[source]

Bases: abc.ABC

The GenericSSCModule class works as a way to intialize, update, and run SSC simulations through PySAM.

This class is not meant to be run, but instead work as a parent class for all other models including NuclearTES, a future CSP class, etc.

NOTE: I over-use the word “module” because everything is apparently a module. There are three hierarchies of modules at play here: - SSC modules : these are the cmod_<name>.cpp files from the SSC repository written in C++ - PySAM modules : these are PySAM wrappers for the SSC modules (also Grid, Financial modules, etc.) - NE2 modules : these are Python classes that create PySAM modules (e.g., THIS class)

abstract __init__(plant_name='abstract', json_name='abstract', dual=False, direct=True, is_dispatch=False, dispatch_time_step=1, log_dispatch_targets=False, exec_debug=False, exec_timeout=10.0, **kwargs)[source]

Initializes the GenericSSCModules

Parameters
  • plant_name (str) – name of SSC module to run

  • json_name (str) – name of JSON script with input data for module

  • is_dispatch (bool) – boolean, if True runs Pyomo dispatch optimization

  • dispatch_time_step (int) – time step for dispatch (hours)

  • log_dispatch_targets (bool) – boolean, if True logs dispatch targets calculated by Pyomo at each segment

  • exec_debug (bool) – boolean, allows execution in “debug” mode that times out exec call

  • exec_timeout (float) – amount of time in seconds to timeout an exec call

advance_time_segment(prev_time_start, prev_time_next)[source]

Method to advance time segment to the next horizon

This method updates the current time segment bookends and slices to reflect the next time segment horizon.

Parameters
  • prev_time_start (float Quant) – starting time of previous time segment

  • prev_time_next (float Quant) – ending time of previous time segment

Returns

starting time of current SSC horizon time_sscH (float Quant):

ending time of current SSC horizon

time_pyoH (float Quant):

ending time of current SSC horizon

Return type

time_start (float Quant)

abstract create_Grid()[source]

Method to create Grid onuclear_mspt_indirect_tesbject for the first time

This method creates a Grid object again using built-in PySAM functions. The Grid object is created similarly to the Plant object, from SSC inputs listed in the SSC_dict. The Grid object, however, is first created from the existing Plant object and then the grid-specific input data is added to create a wrapper for the SSC Grid module.

abstract create_Plant()[source]

Method to create Plant object for the first time

This method creates a Plant object using built-in PySAM functionalities (including some former PySSC structures). Essentially, it creates some sort of data structure (pointer?) from SSC inputs found in the SSC_dict and the specified SSC module. That data structure is then used to create a PySAM module for the specified SSC Plant module (TCSMolten_Salt, etc.).

create_SO()[source]

Method to create SingleOwner object for the first time

This method creates a Financial object–in this case, the “SingleOwner” SSC financial module– using PySAM like before. Similarly to the Grid object, the SingleOwner object is created first from the existing Plant object and then SingleOwner-specific input data is added to create a wrapper for the SSC SingleOwner module.

abstract create_dispatch_params(Plant)[source]

Populating a dictionary with dispatch parameters before optimization

Note

self.is_dispatch == True (Called within simulation)

This method is creates the Dispatch Parameter dictionary that will be populated with static inputs from SSC_dict as well as initial conditions for Dispatch optimization. The initial conditions are continuously updated if simulation is segmented.

Parameters

Plant (obj) – original PySAM Plant module

Returns

wrapper object for the class that creates dispatch parameters

Return type

dispatch_wrap (obj)

abstract create_dispatch_wrapper(PySAM_dict)[source]

Creating a wrapper object for calling a class that creates dispatch parameters

Note

self.is_dispatch == True (Called in __init__ of NE2 module)

This method creates an object whose class ultimately calculates and creates parameters for Dispatch optimization. The reason this class exists separately is that it gets overlaoded based on the PySAM module we are running. Depending on the PySAM module, this method calls on a different Dispatch Parameter class that is specific to the module.

Parameters

PySAM_dict (dict) – dictionary of PySAM inputs from a script in /json directory

Returns

wrapper object for the class that creates dispatch parameters

Return type

dispatch_wrap (obj)

abstract duplicate_Plant(Plant)[source]

Method to create Plant object as a duplicate of existing Plant

This method creates a Plant object from an existing Plant. The new Plant object will have a copy of the original Plant’s subclasses EXCEPT the Output subclass. The two plant’s outputs will NOT be linked.

Note

Currently verified in simulations/scripts/sanity_check_scripts

Parameters

Plant (obj) – original PySAM Plant module to be copied

Returns

duplicate PySAM Plant module, unlinked from original

Return type

newPlant (obj)

export_results(filename)[source]

Exports final SSC outputs to a specified Excel file

This method creates an .xlsx file with SSC output data from the full simulation. Outputs are specified by keywords in the JSON script supplied by the user.

Parameters

filename (str) – name of xlsx file to save results to within /output directory

abstract generate_hash()[source]

Method to create unique hash for given JSON inputs

This method creates a unique, permanent hash for a given JSON script. That is, it gathers all of the JSON inputs (including SSC and PySAM inputs) from the designated script and converts both their keynames and values to strings. It collects all of these into a single string variable and then creates a new hexadecimal string or “hash” for that giant string. This serves as a unique identifier or “fingerprint” for all the values in the JSON script. This is then used later on as the file name containing outputs from this particular run. Any small changes to the JSON script will result in a drastically different hash, and therefore a new output file. If a simulation has already been run with the given JSON script, it can just pull results from the already created hash file instead of needlessly repeating the simulation.

Returns

if True, a hash file currently exists with all given JSON inputs filepath (str):

absolute filepath to the hash file in outputs directory

Return type

hash_exists (bool)

abstract initialize_arrays()[source]

Initializing empty arrays to log SSC outputs after segment simulations

This method creates empty arrays where SSC outputs will be written to. Also creates a list of str names for logged simulation outputs.

initialize_time_elements()[source]

Method to initialize time elements

This method initiliazes start and end times for full simulation and conducts logic for end of next time segment (could be SSC horizon, or could be end time).

Returns

starting time of current SSC horizon time_sscH (float Quant):

ending time of current SSC horizon

Return type

time_start (float Quant)

initialize_time_slices(time_start)[source]

Method to advance time segment to the next horizon

This method updates the current time segment bookends and slices to reflect the next time segment horizon.

Parameters

time_start (float Quant) – starting time of current SSC horizon

log_SSC_arrays(log_final=False)[source]

Creating a wrapper object for calling a class that creates dispatch parameters

This method logs SSC outputs if we choose to run a segmented simulation in a loop. Normally (if log_final == False) it saves outputs to arrays that are members of the GenericSSCModule class; these are previously initialized to 0. (If log_final == True) the method gets all the previously logged and filled arrays from the segmented simulation and saves it to the Plant object which is a member class of GenericSSCModule. The Plant member class gets a “dummy” subclass made from an empty lambda function but works as a class with attributes saved to it.

Parameters

log_final (bool) – if true, save full outputs to Plant. else, log to member arrays of Plant

reset_all()[source]

Reset SSC submodules

This method resets all PySAM wrappers, deleting them from this NE2 class. Primarily done for unit testing, but could also have use if running simulations in parallel.

run_Plant_through_SSC(Plant, start_hr, end_hr)[source]

Simulation of Plant through SSC for given times

This method strictly executes the Plant object in SSC through the PySAM wrapper. It updates the start and end times of the simulation in case we are running a subsequent segment of the simulation but also handles full, un-segmented simulations. If running in segments, it stores outputs to member attributes of this NE2 module.

Parameters
  • Plant (obj) – original PySAM Plant module to be executed

  • start_hr (float Quant) – starting time for next simulation (hours)

  • end_hr (float Quant) – ending time for next simulation (hours)

Returns

True if SSC execution is successful Plant (obj):

original PySAM Plant module after execution

Return type

exec_success (bool)

abstract run_pyomo(params)[source]

Running Pyomo dispatch optimization

Note

self.is_dispatch == True

This method strictly runs the Pyomo optimization before execution of an SSC segment. It creates a new Dispatch model for the segment, solves it, then returns results. Results are stored in a dictionary.

Parameters

params (dict) – dictionary of Pyomo dispatch parameters

run_sim(run_loop=False, export=False, filename='temp.csv', overwrite_dispatch_targets=False)[source]

Method to run single simulation for Generic System

This method handles the creating and execution of Plant, Grid, and Financial objects to run through SSC. The Plant has an optional boolean input to allow the running of a full simulation in a segmented loop.

Parameters
  • run_loop (bool) – if true, runs simulation in segments. else, runs simulation all at once

  • export (bool) – if true, exports results to an Excel sheet

  • filename (str) – name for Excel sheet saved to the /outputs directory

  • overwrite_dispatch_targets (bool) – if true, overwrites the current stored dispatch target file

simulate_Plant()[source]

Method to run full simulation of Plant

This method is a sub-section of the run_sim() method in that it handles the execution of JUST the Plant object simulation. However, this constitutes most of the SSC computational cost. Namely, this method carries out the setup steps and calls a method to execute the Plant in SSC through the PySAM wrapper.

Major features:
  1. “run_loop” (bool) - We can choose to run the simulation all at once,

    or run it in segments defined by our “SSC Horizon” defined in the JSON script.

  2. “is_dispatch” (bool) - We can also choose to run Dispatch optimization

    through a Python package called Pyomo, then use those results to update our SSC inputs.

The Pyomo optimization is generally conducted over a “Pyomo Horizon” longer than the SSC Horizon, but results are only kept for that SSC Horizon to use in the next simulation segment.

abstract store_csv_arrays(input_dict)[source]

Method to get data from specified csv files and store in class

This method uses the designated PySAM inputs from a JSON script to extract csv arrays for use in SSC. The PySAM inputs used here are relative filepaths to find the respective csv files. We then either save the filepath as a variable or extract the data from the named csv file and save it to as a member attribute of this NE2 module class.

Parameters

input_dict (dict) – dictionary with csc relative filepaths

abstract update_Plant_after_Pyomo(Plant, pre_dispatch_run=False)[source]

Update SSC Plant inputs with Pyomo optimization outputs from current segment simulation

Note

self.run_loop == True (can be called outside loop) self.is_dispatch == True

This method uses the optimization results from Pyomo and ensures that the next SSC segment uses them throughout the corresponding SSC Horizon. SSC normally takes single values for initial conditions (for the first hour of the SSC Horizon), but it can also take in an array of values for each step in the SSC Horizon. These are called “dispatch_targets”. Steps are: (1) extract solutions from Pyomo over the Pyomo Horizon, (2) keep the solutions for the shorter SSC Horizon and (3) save these “dispatch target” inputs to the Plant object for the next SSC simulation segment.

Parameters
  • Plant (obj) – original PySAM Plant module to be updated

  • pre_dispatch_run (bool) – are we updating the Plant for a pre- or post- dispatch run. Recall that we only log post-dispatch Plant runs

Returns

updated PySAM Plant module

Return type

Plant (obj)

update_Plant_after_SSC()[source]

Update SSC Plant inputs with SSC outputs from previous segment simulation

Note

self.run_loop == True

This method uses the SSC end results from the previous simulation segment and sets them as the initial conditions for the next SSC segment. As a small note: some outputs are arrays that span the full year, however the only relevant parts are the first indeces corresponding to the SSC Horizon. All other values are typically 0.

abstract update_Pyomo_after_SSC(Plant, params)[source]

Update Pyomo inputs with SSC outputs from previous segment simulation

Note

self.run_loop == True self.is_dispatch == True

This method uses the SSC end results from the previous simulation segment and uses them to update the existing Dispatch parameter dictionary that is ultimately sent to Pyomo. Essentially just updates the initial conditions of the Dispatch parameter dictionary.

Parameters
  • Plant (obj) – original PySAM Plant module

  • params (dict) – dictionary of Pyomo dispatch parameters

Returns

updated dictionary of Pyomo dispatch parameters

Return type

params (dict)

simulations.modules.IndirectNuclearTES module

Created on Fri Apr 8 16:58:30 2022

@author: gabrielsoto

class simulations.modules.IndirectNuclearTES.IndirectNuclearTES(plant_name='nuclear_mspt_indirect_tes', json_name='model1', **kwargs)[source]

Bases: modules.NuclearTES.NuclearTES

The IndirectNuclearTES class intializes, updates, and runs SSC simulations through PySAM, specifically for the SSC tcsmolten_salt module.

__init__(plant_name='nuclear_mspt_indirect_tes', json_name='model1', **kwargs)[source]

Initializes the SolarTES module

Inputs:

plant_name (str) : name of SSC module to run json_name (str) : name of JSON script with input data for module is_dispatch (bool) : boolean, if True runs Pyomo dispatch optimization

create_dispatch_params(Plant)[source]

Populating a dictionary with dispatch parameters before optimization

Note

self.is_dispatch == True (Called within simulation)

This method is creates the Dispatch Parameter dictionary that will be populated with static inputs from SSC_dict as well as initial conditions for Dispatch optimization. The initial conditions are continuously updated if simulation is segmented.

Parameters

Plant (obj) – original PySAM Plant module

Returns

wrapper object for the class that creates dispatch parameters

Return type

dispatch_wrap (obj)

create_dispatch_wrapper(PySAM_dict)[source]

Creating a wrapper object for calling a class that creates dispatch parameters

** self.is_dispatch == True (Called in __init__ of NE2 module)

This method creates an object whose class ultimately calculates and creates parameters for Dispatch optimization. The reason this class exists separately is that it gets overlaoded based on the PySAM module we are running. Depending on the PySAM module, this method calls on a different Dispatch Parameter class that is specific to the module.

Inputs:

PySAM_dict (dict) : dictionary of PySAM inputs from a script in /json directory

Outputs:

dispatch_wrap (obj) : wrapper object for the class that creates dispatch parameters

initialize_arrays()[source]

Initializing empty arrays to log SSC outputs after segment simulations

This method creates empty arrays where SSC outputs will be written to. Also creates a list of str names for logged simulation outputs.

update_Plant_after_Pyomo(Plant, pre_dispatch_run=False)[source]

Update SSC Plant inputs with Pyomo optimization outputs from current segment simulation

Note

self.run_loop == True (can be called outside loop) self.is_dispatch == True

This method uses the optimization results from Pyomo and ensures that the next SSC segment uses them throughout the corresponding SSC Horizon. SSC normally takes single values for initial conditions (for the first hour of the SSC Horizon), but it can also take in an array of values for each step in the SSC Horizon. These are called “dispatch_targets”. Steps are: (1) extract solutions from Pyomo over the Pyomo Horizon, (2) keep the solutions for the shorter SSC Horizon and (3) save these “dispatch target” inputs to the Plant object for the next SSC simulation segment.

Parameters
  • Plant (obj) – original PySAM Plant module to be updated

  • pre_dispatch_run (bool) – are we updating the Plant for a pre- or post- dispatch run. Recall that we only log post-dispatch Plant runs

Returns

updated PySAM Plant module

Return type

Plant (obj)

simulations.modules.NuclearTES module

Created on Thu Apr 8 13:44:30 2021

@author: gabrielsoto

class simulations.modules.NuclearTES.NuclearTES(plant_name='nuclear_tes', json_name='model1', **kwargs)[source]

Bases: modules.GenericSSCModule.GenericSSCModule

The NuclearTES class intializes, updates, and runs SSC simulations through PySAM, specifically for the SSC NuclearTES module.

__init__(plant_name='nuclear_tes', json_name='model1', **kwargs)[source]

Initializes the NuclearTES module

Parameters
  • plant_name (str) – name of SSC module to run

  • json_name (str) – name of JSON script with input data for module

  • is_dispatch (bool) – boolean, if True runs Pyomo dispatch optimization

  • log_dispatch_targets (bool) – boolean, if True logs dispatch targets calculated by Pyomo at each segment

create_Grid()[source]

Method to create Grid object for the first time

This method creates a Grid object again using built-in PySAM functions. The Grid object is created similarly to the Plant object, from SSC inputs listed in the SSC_dict. The Grid object, however, is first created from the existing Plant object and then the grid-specific input data is added to create a wrapper for the SSC Grid module.

create_Plant()[source]

Method to create Plant object for the first time

This method creates a Plant object using built-in PySAM functionalities (including some former PySSC structures). Essentially, it creates some sort of data structure (pointer?) from SSC inputs found in the SSC_dict and the specified SSC module. That data structure is then used to create a PySAM module for the specified SSC Plant module (TCSMolten_Salt, etc.).

create_dispatch_params(Plant)[source]

Populating a dictionary with dispatch parameters before optimization

Note

self.is_dispatch == True (Called within simulation)

This method is creates the Dispatch Parameter dictionary that will be populated with static inputs from SSC_dict as well as initial conditions for Dispatch optimization. The initial conditions are continuously updated if simulation is segmented.

Parameters

Plant (obj) – original PySAM Plant module

Returns

wrapper object for the class that creates dispatch parameters

Return type

dispatch_wrap (obj)

create_dispatch_wrapper(PySAM_dict)[source]

Creating a wrapper object for calling a class that creates dispatch parameters

Note

self.is_dispatch == True (Called in __init__ of NE2 module)

This method creates an object whose class ultimately calculates and creates parameters for Dispatch optimization. The reason this class exists separately is that it gets overlaoded based on the PySAM module we are running. Depending on the PySAM module, this method calls on a different Dispatch Parameter class that is specific to the module.

Parameters

PySAM_dict (dict) – dictionary of PySAM inputs from a script in /json directory

Returns

wrapper object for the class that creates dispatch parameters

Return type

dispatch_wrap (obj)

duplicate_Plant(Plant)[source]

Method to create Plant object as a duplicate of existing Plant

This method creates a Plant object from an existing Plant. The new Plant object will have a copy of the original Plant’s subclasses EXCEPT the Output subclass. The two plant’s outputs will NOT be linked.

Note

Verified in simulations/scripts/sanity_check_scripts

Parameters

Plant (obj) – original PySAM Plant module to be copied

Returns

duplicate PySAM Plant module, unlinked from original

Return type

newPlant (obj)

generate_hash()[source]

Method to create unique hash for given JSON inputs

This method creates a unique, permanent hash for a given JSON script. That is, it gathers all of the JSON inputs (including SSC and PySAM inputs) from the designated script and converts both their keynames and values to strings. It collects all of these into a single string variable and then creates a new hexadecimal string or “hash” for that giant string. This serves as a unique identifier or “fingerprint” for all the values in the JSON script. This is then used later on as the file name containing outputs from this particular run. Any small changes to the JSON script will result in a drastically different hash, and therefore a new output file. If a simulation has already been run with the given JSON script, it can just pull results from the already created hash file instead of needlessly repeating the simulation.

Returns

if True, a hash file currently exists with all given JSON inputs filepath (str):

absolute filepath to the hash file in outputs directory

Return type

hash_exists (bool)

initialize_arrays()[source]

Initializing empty arrays to log SSC outputs after segment simulations

This method creates empty arrays where SSC outputs will be written to. Also creates a list of str names for logged simulation outputs.

run_pyomo(params)[source]

Running Pyomo dispatch optimization

Note

self.is_dispatch == True

This method strictly runs the Pyomo optimization before execution of an SSC segment. It creates a new Dispatch model for the segment, solves it, then returns results. Results are stored in a dictionary. Help with failure modes was found through here: https://www.pyomo.org/blog/2015/1/8/accessing-solver

Parameters

params (dict) – dictionary of Pyomo dispatch parameters

Returns

if dispatch model was solved successfully, returns True

Return type

dispatch_success (bool)

store_csv_arrays(input_dict)[source]

Method to get data from specified csv files and store in class

This method uses the designated PySAM inputs from a JSON script to extract csv arrays for use in SSC. The PySAM inputs used here are relative filepaths to find the respective csv files. We then either save the filepath as a variable or extract the data from the named csv file and save it to as a member attribute of this NE2 module class.

Parameters

input_dict (dict) – dictionary with csv relative filepaths

update_Plant_after_Pyomo(Plant, pre_dispatch_run=False)[source]

Update SSC Plant inputs with Pyomo optimization outputs from current segment simulation

Note

self.run_loop == True (can be called outside loop) self.is_dispatch == True

This method uses the optimization results from Pyomo and ensures that the next SSC segment uses them throughout the corresponding SSC Horizon. SSC normally takes single values for initial conditions (for the first hour of the SSC Horizon), but it can also take in an array of values for each step in the SSC Horizon. These are called “dispatch_targets”. Steps are: (1) extract solutions from Pyomo over the Pyomo Horizon, (2) keep the solutions for the shorter SSC Horizon and (3) save these “dispatch target” inputs to the Plant object for the next SSC simulation segment.

Parameters
  • Plant (obj) – original PySAM Plant module to be updated

  • pre_dispatch_run (bool) – are we updating the Plant for a pre- or post- dispatch run. Recall that we only log post-dispatch Plant runs

Returns

updated PySAM Plant module

Return type

Plant (obj)

update_Pyomo_after_SSC(Plant, params)[source]

Update Pyomo inputs with SSC outputs from previous segment simulation

Note

self.run_loop == True self.is_dispatch == True

This method uses the SSC end results from the previous simulation segment and uses them to update the existing Dispatch parameter dictionary that is ultimately sent to Pyomo. Essentially just updates the initial conditions of the Dispatch parameter dictionary.

Parameters
  • Plant (obj) – original PySAM Plant module

  • params (dict) – dictionary of Pyomo dispatch parameters

Returns

updated dictionary of Pyomo dispatch parameters

Return type

params (dict)

simulations.modules.SolarTES module

Created on Fri Jul 16 13:49:24 2021

@author: gabrielsoto

class simulations.modules.SolarTES.SolarTES(plant_name='tcsmolten_salt', json_name='model_solarTES', **kwargs)[source]

Bases: modules.IndirectNuclearTES.IndirectNuclearTES, modules.NuclearTES.NuclearTES

The SolarTES class intializes, updates, and runs SSC simulations through PySAM, specifically for the SSC tcsmolten_salt module.

__init__(plant_name='tcsmolten_salt', json_name='model_solarTES', **kwargs)[source]

Initializes the SolarTES module

Inputs:

plant_name (str) : name of SSC module to run json_name (str) : name of JSON script with input data for module is_dispatch (bool) : boolean, if True runs Pyomo dispatch optimization

create_dispatch_params(Plant)[source]

Populating a dictionary with dispatch parameters before optimization

Note

self.is_dispatch == True (Called within simulation)

This method is creates the Dispatch Parameter dictionary that will be populated with static inputs from SSC_dict as well as initial conditions for Dispatch optimization. The initial conditions are continuously updated if simulation is segmented.

Parameters

Plant (obj) – original PySAM Plant module

Returns

wrapper object for the class that creates dispatch parameters

Return type

dispatch_wrap (obj)

create_dispatch_wrapper(PySAM_dict)[source]

Creating a wrapper object for calling a class that creates dispatch parameters

** self.is_dispatch == True (Called in __init__ of NE2 module)

This method creates an object whose class ultimately calculates and creates parameters for Dispatch optimization. The reason this class exists separately is that it gets overlaoded based on the PySAM module we are running. Depending on the PySAM module, this method calls on a different Dispatch Parameter class that is specific to the module.

Inputs:

PySAM_dict (dict) : dictionary of PySAM inputs from a script in /json directory

Outputs:

dispatch_wrap (obj) : wrapper object for the class that creates dispatch parameters

initialize_arrays()[source]

Initializing empty arrays to log SSC outputs after segment simulations

This method creates empty arrays where SSC outputs will be written to. Also creates a list of str names for logged simulation outputs.

update_Plant_after_Pyomo(Plant, pre_dispatch_run=False)[source]

Update SSC Plant inputs with Pyomo optimization outputs from current segment simulation

Note

self.run_loop == True (can be called outside loop) self.is_dispatch == True

This method uses the optimization results from Pyomo and ensures that the next SSC segment uses them throughout the corresponding SSC Horizon. SSC normally takes single values for initial conditions (for the first hour of the SSC Horizon), but it can also take in an array of values for each step in the SSC Horizon. These are called “dispatch_targets”. Steps are: (1) extract solutions from Pyomo over the Pyomo Horizon, (2) keep the solutions for the shorter SSC Horizon and (3) save these “dispatch target” inputs to the Plant object for the next SSC simulation segment.

Parameters
  • Plant (obj) – original PySAM Plant module to be updated

  • pre_dispatch_run (bool) – are we updating the Plant for a pre- or post- dispatch run. Recall that we only log post-dispatch Plant runs

Returns

updated PySAM Plant module

Return type

Plant (obj)

update_Plant_after_SSC()[source]

Update SSC Plant inputs with SSC outputs from previous segment simulation

** self.run_loop == True

This method uses the SSC end results from the previous simulation segment and sets them as the initial conditions for the next SSC segment. As a small note: some outputs are arrays that span the full year, however the only relevant parts are the first indeces corresponding to the SSC Horizon. All other values are typically 0.

update_Pyomo_after_SSC(Plant, params)[source]

Update Pyomo inputs with SSC outputs from previous segment simulation

Note

self.run_loop == True self.is_dispatch == True

This method uses the SSC end results from the previous simulation segment and uses them to update the existing Dispatch parameter dictionary that is ultimately sent to Pyomo. Essentially just updates the initial conditions of the Dispatch parameter dictionary.

Parameters
  • Plant (obj) – original PySAM Plant module

  • params (dict) – dictionary of Pyomo dispatch parameters

Returns

updated dictionary of Pyomo dispatch parameters

Return type

params (dict)