simulations.dispatch package¶
Submodules¶
simulations.dispatch.DualIndirectDispatch module¶
Created on Thu Apr 14 13:20:58 2022
@author: gabrielsoto
- class simulations.dispatch.DualIndirectDispatch.DualIndirectDispatch(dual=True, direct=False, **kwargs)[source]¶
Bases:
dispatch.SolarDispatch.SolarDispatch
The DualPlantDispatch class is meant to set up and run Dispatch optimization as a mixed integer linear program problem using Pyomo, specifically for the NuclearMsptTES NE2+SSC module.
- __init__(dual=True, direct=False, **kwargs)[source]¶
Initializes the IndirectDualDispatch module
The instantiation of this class receives a parameter dictionary from the NE2 module (created using the DualPlantDispatchWrapper class). It calls on the GeneralDispatch __init__ to create the model. The NuclearDispatch first creates an empty Concrete Model from Pyomo, then generates Parameters from the parameter dictionary, Variables, Objectives and Constraints.
- Inputs:
params (dict) : dictionary of Pyomo dispatch parameters unitRegistry (pint.registry) : unique unit Pint unit registry
- addPiecewiseLinearEfficiencyConstraints()[source]¶
Method to add efficiency constraints to the Pyomo Solar Model
This method adds constraints pertaining to efficiency constraints defined as a piecewise linear approximation. Also referred to as Cycle supply and demand constraints. In the SolarDispatch, we add an extra balance of power with respect to energy storage and power produced from the CSP plant.
TODO: This should be revisited when adding MED!!
- addTESEnergyBalanceConstraints()[source]¶
Method to add TES constraints to the Pyomo Solar Model
This method adds constraints pertaining to TES energy balance from charging with thermal power and discharging to the power cycle.
- add_objective()[source]¶
Method to add an objective function to the Pyomo Solar Model
This method adds an objective function to the Pyomo Solar Dispatch model. Typically, the LORE team defined a nested function and passes it into the Pyomo model.
- generate_constraints()[source]¶
Method to add ALL constraints to the Pyomo Solar Model
This method calls the previously defined constraint methods to instantiate them and add to the existing model. This method first calls the GeneralDispatch version to set PowerCycle constraints, then calls nuclear constraint methods to add them to the model.
- generate_params(params)[source]¶
Method to generate parameters within Pyomo DualPlant Model
This method reads in a dictionary of pyomo parameters and uses these inputs to initialize parameters for the Pyomo Concrete Model. This method sets up parameters particularly for the Power Cycle. It also defines some lambda functions that helps convert Pint units to Pyomo units. It first instantiates PowerCycle parameters through GeneralDispatch, then instantiates Nuclear parameters.
Note: initial conditions are defined for the time period immediately preceding the start of this new Pyomo time segment.
- Inputs:
params (dict) : dictionary of Pyomo dispatch parameters
- generate_variables()[source]¶
Method to generate parameters within Pyomo DualPlant Model
This method instantiates variables for the Pyomo Concrete Model, with domains. Does not need initial guesses here, they are defined in the parameters. We first define continuous and binary variables for the Power Cycle through GeneralDispatch, then declare nuclear variables.
- class simulations.dispatch.DualIndirectDispatch.DualIndirectDispatchOutputs[source]¶
Bases:
object
The IndirectNuclearDispatchOutputs class is meant to handle outputs from a given, solved Pyomo Dispatch model. It returns desired outputs in appropriate formats and syntaxes for PostProcessing and linking simulation segments between Pyomo and SSC calls.
- get_dispatch_targets_from_Pyomo(horizon, N_full, run_loop=False)[source]¶
Method to set fixed costs of the Plant
This method parses through the solved Pyomo model for Dispatch optimization and extracts results that are used as Dispatch Targets in the SAME simulation segment but in SSC rather than Pyomo. If we’re not running a loop, we can still update SSC only I guess this happens once for whatever Pyomo horizon is defined (this might not be a feature we keep long-term, perhaps only for
debugging).
- Inputs:
dispatch_model (Pyomo model) : solved Pyomo Dispatch model (ConcreteModel) horizon (float Quant) : length of time of horizon, whether SSC or Pyomo (in hours) N_full (int) : length of full simulation time (in hours, no Quant) run_loop (bool) : flag to determine if simulation is segmented
- Outputs:
disp_targs (dict) : dictionary of dispatch target arrays for use in SSC
- class simulations.dispatch.DualIndirectDispatch.DualIndirectDispatchParamWrap(dual=True, direct=False, **kwargs)[source]¶
Bases:
dispatch.SolarDispatch.SolarDispatchParamWrap
The DualPlantDispatchParamWrap class is meant to be the staging area for the creation of Parameters ONLY for the DualPlantDispatch class. It communicates with the NE2 modules, receiving SSC and PySAM input dictionaries to calculate both static parameters used for every simulation segment AND initial conditions that can be updated.
- __init__(dual=True, direct=False, **kwargs)[source]¶
Initializes the NuclearDispatchParamWrap module
- Inputs:
unitRegistry (pint.registry) : unique unit Pint unit registry SSC_dict (dict) : dictionary of SSC inputs needed to run modules PySAM_dict (dict) : dictionary of PySAM inputs + file names pyomo_horizon (int Quant) : length of Pyomo simulation segment (hours) dispatch_time_step (int Quant) : length of each Pyomo time step (hours)
- set_design()[source]¶
Method to calculate and save design point values of Plant operation
This method extracts values and calculates for design point parameters of our Plant (e.g., nuclear thermal power output, power cycle efficiency, inlet and outlet temperatures, etc.).
- set_fixed_cost_parameters(param_dict)[source]¶
Method to set fixed costs of the Plant
This method calculates some fixed costs for the Plant operations, startup, standby, etc.
- Inputs:
param_dict (dict) : dictionary of Pyomo dispatch parameters
- Outputs:
param_dict (dict) : updated dictionary of Pyomo dispatch parameters
- set_initial_state(param_dict, updated_dict=None, plant=None, npts=None)[source]¶
Method to set the initial state of the Plant before Dispatch optimization
This method uses SSC data to set the initial state of the Plant before Dispatch optimization in Pyomo. This method is called in two ways: once before starting the simulation loop, in which case it only uses values from the SSC_dict portion of the given JSON script. The method is also called within the simulation loop to update the initial state parameters based on the ending conditions of the previous simulation segment (provided by SSC).
TODO: can we just input another dictionary instead of passing the full Plant?
- Inputs:
param_dict (dict) : dictionary of Pyomo dispatch parameters updated_dict (dict) : dictionary with updated SSC initial conditions from previous run plant (obj) : the full PySAM Plant object. npts (int) : length of the SSC horizon
- Outputs:
param_dict (dict) : updated dictionary of Pyomo dispatch parameters
simulations.dispatch.DualPlantDispatch module¶
Pyomo real-time dispatch model
Model authors: * Mike Wagner - UW-Madison * Bill Hamilton - NREL * John Cox - Colorado School of Mines * Alex Zolan - NREL
Pyomo code by Alex Zolan Modified by Gabriel Soto
- class simulations.dispatch.DualPlantDispatch.DualPlantDispatch(dual=True, **kwargs)[source]¶
Bases:
dispatch.SolarDispatch.SolarDispatch
The DualPlantDispatch class is meant to set up and run Dispatch optimization as a mixed integer linear program problem using Pyomo, specifically for the NuclearMsptTES NE2+SSC module.
- __init__(dual=True, **kwargs)[source]¶
Initializes the DualPlantDispatch module
The instantiation of this class receives a parameter dictionary from the NE2 module (created using the DualPlantDispatchWrapper class). It calls on the GeneralDispatch __init__ to create the model. The NuclearDispatch first creates an empty Concrete Model from Pyomo, then generates Parameters from the parameter dictionary, Variables, Objectives and Constraints.
- Inputs:
params (dict) : dictionary of Pyomo dispatch parameters unitRegistry (pint.registry) : unique unit Pint unit registry
- addNuclearSupplyAndDemandConstraints()[source]¶
Method to add nuclear supply and demand constraints to the Pyomo Nuclear Model
This method adds constraints pertaining to nuclear supply and demand energy constraints. Some constraints might be redundant, they are adapted from the CSP constraints (thanks LORE team).
- addPiecewiseLinearEfficiencyConstraints()[source]¶
Method to add efficiency constraints to the Pyomo Solar Model
This method adds constraints pertaining to efficiency constraints defined as a piecewise linear approximation. Also referred to as Cycle supply and demand constraints. In the SolarDispatch, we add an extra balance of power with respect to energy storage and power produced from the CSP plant.
TODO: This should be revisited when adding MED!!
- addTESEnergyBalanceConstraints()[source]¶
Method to add TES constraints to the Pyomo Solar Model
This method adds constraints pertaining to TES energy balance from charging with thermal power and discharging to the power cycle.
- add_objective()[source]¶
Method to add an objective function to the Pyomo Solar Model
This method adds an objective function to the Pyomo Solar Dispatch model. Typically, the LORE team defined a nested function and passes it into the Pyomo model.
- generate_constraints()[source]¶
Method to add ALL constraints to the Pyomo Solar Model
This method calls the previously defined constraint methods to instantiate them and add to the existing model. This method first calls the GeneralDispatch version to set PowerCycle constraints, then calls nuclear constraint methods to add them to the model.
- generate_params(params)[source]¶
Method to generate parameters within Pyomo DualPlant Model
This method reads in a dictionary of pyomo parameters and uses these inputs to initialize parameters for the Pyomo Concrete Model. This method sets up parameters particularly for the Power Cycle. It also defines some lambda functions that helps convert Pint units to Pyomo units. It first instantiates PowerCycle parameters through GeneralDispatch, then instantiates Nuclear parameters.
Note: initial conditions are defined for the time period immediately preceding the start of this new Pyomo time segment.
- Inputs:
params (dict) : dictionary of Pyomo dispatch parameters
- generate_variables()[source]¶
Method to generate parameters within Pyomo DualPlant Model
This method instantiates variables for the Pyomo Concrete Model, with domains. Does not need initial guesses here, they are defined in the parameters. We first define continuous and binary variables for the Power Cycle through GeneralDispatch, then declare nuclear variables.
- class simulations.dispatch.DualPlantDispatch.DualPlantDispatchParamWrap(dual=True, **kwargs)[source]¶
Bases:
dispatch.SolarDispatch.SolarDispatchParamWrap
The DualPlantDispatchParamWrap class is meant to be the staging area for the creation of Parameters ONLY for the DualPlantDispatch class. It communicates with the NE2 modules, receiving SSC and PySAM input dictionaries to calculate both static parameters used for every simulation segment AND initial conditions that can be updated.
- __init__(dual=True, **kwargs)[source]¶
Initializes the NuclearDispatchParamWrap module
- Inputs:
unitRegistry (pint.registry) : unique unit Pint unit registry SSC_dict (dict) : dictionary of SSC inputs needed to run modules PySAM_dict (dict) : dictionary of PySAM inputs + file names pyomo_horizon (int Quant) : length of Pyomo simulation segment (hours) dispatch_time_step (int Quant) : length of each Pyomo time step (hours)
- set_design()[source]¶
Method to calculate and save design point values of Plant operation
This method extracts values and calculates for design point parameters of our Plant (e.g., nuclear thermal power output, power cycle efficiency, inlet and outlet temperatures, etc.).
- set_fixed_cost_parameters(param_dict)[source]¶
Method to set fixed costs of the Plant
This method calculates some fixed costs for the Plant operations, startup, standby, etc.
- Inputs:
param_dict (dict) : dictionary of Pyomo dispatch parameters
- Outputs:
param_dict (dict) : updated dictionary of Pyomo dispatch parameters
- set_initial_state(param_dict, updated_dict=None, plant=None, npts=None)[source]¶
Method to set the initial state of the Plant before Dispatch optimization
This method uses SSC data to set the initial state of the Plant before Dispatch optimization in Pyomo. This method is called in two ways: once before starting the simulation loop, in which case it only uses values from the SSC_dict portion of the given JSON script. The method is also called within the simulation loop to update the initial state parameters based on the ending conditions of the previous simulation segment (provided by SSC).
TODO: can we just input another dictionary instead of passing the full Plant?
- Inputs:
param_dict (dict) : dictionary of Pyomo dispatch parameters updated_dict (dict) : dictionary with updated SSC initial conditions from previous run plant (obj) : the full PySAM Plant object. npts (int) : length of the SSC horizon
- Outputs:
param_dict (dict) : updated dictionary of Pyomo dispatch parameters
simulations.dispatch.GeneralDispatch module¶
Pyomo real-time dispatch model
Model authors: * Mike Wagner - UW-Madison * Bill Hamilton - NREL * John Cox - Colorado School of Mines * Alex Zolan - NREL
Pyomo code by Alex Zolan Modified by Gabriel Soto
- class simulations.dispatch.GeneralDispatch.GeneralDispatch(unitRegistry, dual=False, direct=True, **kwargs)[source]¶
Bases:
abc.ABC
The GeneralDispatch class is meant to set up and run Dispatch optimization as a mixed integer linear program problem using Pyomo. It creates a ConcreteModel in Pyomo with Parameters, Variables, Objectives, and Constraints. The ConcreteModel can then be solved.
This is the base/parent class and should not be run by itself. Essentially, this sets Pyomo with PowerCycle-specific parameters, variables, objectives, and constraints. Derived classes can then be instantiated to add more specific constraints and overload the objective function.
TODO: can we convert this to an abstract class in Python?
- abstract __init__(unitRegistry, dual=False, direct=True, **kwargs)[source]¶
Initializes the GeneralDispatch module
The instantiation of this class receives a parameter dictionary from the NE2 module (created using a DispatchWrapper class in this file but separate from the GeneralDispatch or other Dispatch classes). It first creates an empty Concrete Model from Pyomo, then generates Parameters from the parameter dictionary, Variables, Objectives and Constraints.
- Inputs:
params (dict) : dictionary of Pyomo dispatch parameters unitRegistry (pint.registry) : unique unit Pint unit registry
- addCycleLogicConstraints()[source]¶
Method to add cycle logic constraints to the Pyomo General Model
This method adds constraints pertaining to tracking binary variable logic for the power cycle. Essentially, to make sure the correct modes are activated when they are allowed.
- addCycleStartupConstraints()[source]¶
Method to add cycle startup constraints to the Pyomo General Model
This method adds constraints pertaining to cycle startup within the Pyomo General Dispatch class. Several nested functions are defined.
- addMinUpAndDowntimeConstraints()[source]¶
Method to add up and downtime constraints to the Pyomo General Model
This method adds constraints pertaining to enforcing minimum uptime and downtime of the power cycle whenever it starts or ends operation, respectively.
- addPersistenceConstraints()[source]¶
Method to add persistence constraints to the Pyomo General Model
This method adds constraints pertaining to persistence within the Pyomo General Dispatch class. Namely, it constraints the amount of energy sold into the grid in timestep t+1 relative to timestep t. It makes sure that amount doesn’t fluctuate by too much, whether increansig or decreasing.
- addPiecewiseLinearEfficiencyConstraints()[source]¶
Method to add efficiency constraints to the Pyomo General Model
This method adds constraints pertaining to efficiency constraints defined as a piecewise linear approximation. Also referred to as Cycle supply and demand constraints.
- abstract add_objective()[source]¶
Method to add an objective function to the Pyomo General Model
This method adds an objective function to the Pyomo General Dispatch model. Typically, the LORE team defined a nested function and passes it into the Pyomo model. This version of the method should not be called, is designated as an abstract method.
- eval_ineq(lb, expr, ub=None, strict=False, val=True)[source]¶
Method to evaluate an inequality using pyomo syntax
This is a helper method to evaluate an inequality using the specific pyomo syntax needed to evaluate when solving the model.
- Inputs:
lb (**) : lower bound of inequality expr (**) : middle value of inequality ub (**) : upper bound of inequality (if exists) strict (bool) : strictness of inequality (True means < or >) val (bool) : flag to return value instead of expression
- Outputs:
ineq (logical expr or float) : evaluated expression as a Pyomo object or float
(**) - can either be a float input or a ParamData object
- generate_constraints()[source]¶
Method to add ALL constraints to the Pyomo General Model
This method calls the previously defined constraint methods to instantiate them and add to the existing model. This method can be called from a derived class as well as overloaded.
- generate_params(params)[source]¶
Method to generate parameters within Pyomo General Model
This method reads in a dictionary of pyomo parameters and uses these inputs to initialize parameters for the Pyomo Concrete Model. This method sets up parameters particularly for the Power Cycle. It also defines some lambda functions that helps convert Pint units to Pyomo units.
Note: initial conditions are defined for the time period immediately preceding the start of this new Pyomo time segment.
- Inputs:
params (dict) : dictionary of Pyomo dispatch parameters
- generate_variables()[source]¶
Method to generate parameters within Pyomo General Model
This method instantiates variables for the Pyomo Concrete Model, with domains. Does not need initial guesses here, they are defined in the parameters. Here we define continuous and binary variables for the Power Cycle.
- solve_model(mipgap=0.7, tee=False, run_simple=False)[source]¶
Method to solve the Pyomo model
This method solves the Pyomo Concrete model that has been instantiated and constructed in the __init__ of this class. The MILP (mixed integer linear programming) problem is solved using a CBC (coin-or branch and cut) solver that should be installed prior to solving. It takes in an input for the MIP or Ratio gap. It is a termination condition for the optimization: if the difference between the best known solution and worst known solution (lower and upper bounds, respectively) is lower than this gap, we have found our optimal solution. Here is a good primer:
- Inputs:
- mipgap (float):
minimum gap to find optimal solution
- Outputs:
- results (SolverResults) :
dictionary of solver output after optimization, contains information on convergence, etc.
- class simulations.dispatch.GeneralDispatch.GeneralDispatchOutputs[source]¶
Bases:
object
The GeneralDispatchOutputs class is meant to handle outputs from a given, solved Pyomo Dispatch model. It returns desired outputs in appropriate formats and syntaxes for PostProcessing and linking simulation segments between Pyomo and SSC calls.
- get_dispatch_targets_from_Pyomo(horizon, N_full, run_loop=False)[source]¶
Method to set fixed costs of the Plant
This method parses through the solved Pyomo model for Dispatch optimization and extracts results that are used as Dispatch Targets in the SAME simulation segment but in SSC rather than Pyomo. If we’re not running a loop, we can still update SSC only I guess this happens once for whatever Pyomo horizon is defined (this might not be a feature we keep long-term, perhaps only for
debugging).
- Inputs:
dispatch_model (Pyomo model) : solved Pyomo Dispatch model (ConcreteModel) horizon (float Quant) : length of time of horizon, whether SSC or Pyomo (in hours) N_full (int) : length of full simulation time (in hours, no Quant) run_loop (bool) : flag to determine if simulation is segmented
- Outputs:
disp_targs (dict) : dictionary of dispatch target arrays for use in SSC
- class simulations.dispatch.GeneralDispatch.GeneralDispatchParamWrap(unit_registry, SSC_dict, PySAM_dict, pyomo_horizon, dispatch_time_step, dual=False, direct=True, interpolants=None, **kwargs)[source]¶
Bases:
object
The GeneralDispatchParamWrap class is meant to be the staging area for the creation of Parameters ONLY. It communicates with the NE2 modules, receiving SSC and PySAM input dictionaries to calculate both static parameters used for every simulation segment AND initial conditions that can be updated.
- __init__(unit_registry, SSC_dict, PySAM_dict, pyomo_horizon, dispatch_time_step, dual=False, direct=True, interpolants=None, **kwargs)[source]¶
Initializes the GeneralDispatchParamWrap module
- Inputs:
unitRegistry (pint.registry) : unique unit Pint unit registry SSC_dict (dict) : dictionary of SSC inputs needed to run modules PySAM_dict (dict) : dictionary of PySAM inputs + file names pyomo_horizon (int Quant) : length of Pyomo simulation segment (hours) dispatch_time_step (int Quant) : length of each Pyomo time step (hours)
- set_design()[source]¶
Method to calculate and save design point values of Plant operation
This method extracts values and calculates for design point parameters of our Plant (e.g., nuclear thermal power output, power cycle efficiency, inlet and outlet temperatures, etc.).
- set_fixed_cost_parameters(param_dict)[source]¶
Method to set fixed costs of the Plant
This method calculates some fixed costs for the Plant operations, startup, standby, etc.
- Inputs:
param_dict (dict) : dictionary of Pyomo dispatch parameters
- Outputs:
param_dict (dict) : updated dictionary of Pyomo dispatch parameters
- set_initial_state(param_dict, updated_dict=None, plant=None, npts=None)[source]¶
Method to set the initial state of the Plant before Dispatch optimization
This method uses SSC data to set the initial state of the Plant before Dispatch optimization in Pyomo. This method is called in two ways: once before starting the simulation loop, in which case it only uses values from the SSC_dict portion of the given JSON script. The method is also called within the simulation loop to update the initial state parameters based on the ending conditions of the previous simulation segment (provided by SSC).
TODO: can we just input another dictionary instead of passing the full Plant?
- Inputs:
param_dict (dict) : dictionary of Pyomo dispatch parameters updated_dict (dict) : dictionary with updated SSC initial conditions from previous run plant (obj) : the full PySAM Plant object npts (int) : length of the SSC horizon
- Outputs:
param_dict (dict) : updated dictionary of Pyomo dispatch parameters
- set_power_cycle_parameters(param_dict, ud_array)[source]¶
Method to set parameters specific to Power Cycle for Dispatch optimization
This method calculates some steady-state parameters specific to the power cycle (PC) for use in Dispatch optimization. These parameters generally have to do with thermal ratings, and upper/lower bounds on capacities.
- Inputs:
param_dict (dict) : dictionary of Pyomo dispatch parameters ud_array (list of list) : table of user defined data as nested lists
- Outputs:
param_dict (dict) : updated dictionary of Pyomo dispatch parameters
- set_time_indexed_parameters(param_dict, df_array, ud_array, current_pyomo_slice)[source]¶
Method to set time-indexed parameters for Dispatch optimization
This method calculates time parameters for Pyomo Dispatch optimization. This includes time-step parameters, which by default are set to 1 hr so shouldn’t cause problems.
- Inputs:
param_dict (dict) : dictionary of Pyomo dispatch parameters df_array (array) : array of user defined dispatch factors over simulation time ud_array (list of list) : table of user defined data as nested lists current_pyomo_slice (slice) : range of current pyomo horizon (ints representing hours)
- Outputs:
param_dict (dict) : updated dictionary of Pyomo dispatch parameters
simulations.dispatch.IndirectNuclearDispatch module¶
Pyomo real-time dispatch model
Model authors: * Mike Wagner - UW-Madison * Bill Hamilton - NREL * John Cox - Colorado School of Mines * Alex Zolan - NREL
Pyomo code by Alex Zolan Modified by Gabriel Soto
- class simulations.dispatch.IndirectNuclearDispatch.IndirectNuclearDispatch(**kwargs)[source]¶
Bases:
dispatch.NuclearDispatch.NuclearDispatch
The IndirectNuclearDispatch class is meant to set up and run Dispatch optimization as a mixed integer linear program problem using Pyomo, specifically for the IndirectNuclearTES NE2+SSC module.
- __init__(**kwargs)[source]¶
Initializes the IndirectNuclearDispatch module
The instantiation of this class receives a parameter dictionary from the NE2 module (created using the NuclearDispatchWrapper class). It calls on the GeneralDispatch __init__ to create the model. The GeneralDispatcher first creates an empty Concrete Model from Pyomo, then generates Parameters from the parameter dictionary, Variables, Objectives and Constraints.
- Inputs:
params (dict) : dictionary of Pyomo dispatch parameters unitRegistry (pint.registry) : unique unit Pint unit registry
- addCycleStartupConstraints()[source]¶
Method to add cycle startup constraints to the Pyomo General Model
This method adds constraints pertaining to cycle startup within the Pyomo General Dispatch class. Several nested functions are defined.
- addNuclearSupplyAndDemandConstraints()[source]¶
Method to add nuclear supply and demand constraints to the Pyomo Nuclear Model
This method adds constraints pertaining to nuclear supply and demand energy constraints. Some constraints might be redundant, they are adapted from the CSP constraints (thanks LORE team).
- addPiecewiseLinearEfficiencyConstraints()[source]¶
Method to add efficiency constraints to the Pyomo IndirectNuclear Model
This method adds constraints pertaining to efficiency constraints defined as a piecewise linear approximation. Also referred to as Cycle supply and demand constraints. In the IndirectNuclearDispatch, we add an extra balance of power with respect to energy storage and power producfrom scipy.interpolate import interp1ded from the nuclear reactor.
TODO: This should be revisited when adding MED!!
- addTESEnergyBalanceConstraints()[source]¶
Method to add TES constraints to the Pyomo Nuclear Model
This method adds constraints pertaining to TES energy balance from charging with thermal power and discharging to the power cycle.
TODO: revisit tes_start_up_rule -> do we need this for nuclear? TODO: do we need maintain_tes_rule?
- add_objective()[source]¶
Method to add an objective function to the Pyomo Nuclear Model
This method adds an objective function to the Pyomo Nuclear Dispatch model. Typically, the LORE team defined a nested function and passes it into the Pyomo model.
- generate_constraints(skip_parent=False)[source]¶
Method to add ALL constraints to the Pyomo Nuclear Model
This method calls the previously defined constraint methods to instantiate them and add to the existing model. This method first calls the GeneralDispatch version to set PowerCycle constraints, then calls nuclear constraint methods to add them to the model.
- generate_params(params, skip_parent=False)[source]¶
Method to generate parameters within Pyomo Nuclear Model
This method reads in a dictionary of pyomo parameters and uses these inputs to initialize parameters for the Pyomo Concrete Model. This method sets up parameters particularly for the Power Cycle. It also defines some lambda functions that helps convert Pint units to Pyomo units. It first instantiates PowerCycle parameters through GeneralDispatch, then instantiates Nuclear parameters.
Note: initial conditions are defined for the time period immediately preceding the start of this new Pyomo time segment.
- Inputs:
params (dict) : dictionary of Pyomo dispatch parameters
- generate_variables(skip_parent=False)[source]¶
Method to generate parameters within Pyomo Nuclear Model
This method instantiates variables for the Pyomo Concrete Model, with domains. Does not need initial guesses here, they are defined in the parameters. We first define continuous and binary variables for the Power Cycle through GeneralDispatch, then declare nuclear variables.
- class simulations.dispatch.IndirectNuclearDispatch.IndirectNuclearDispatchOutputs[source]¶
Bases:
object
The IndirectNuclearDispatchOutputs class is meant to handle outputs from a given, solved Pyomo Dispatch model. It returns desired outputs in appropriate formats and syntaxes for PostProcessing and linking simulation segments between Pyomo and SSC calls.
- get_dispatch_targets_from_Pyomo(horizon, N_full, run_loop=False)[source]¶
Method to set fixed costs of the Plant
This method parses through the solved Pyomo model for Dispatch optimization and extracts results that are used as Dispatch Targets in the SAME simulation segment but in SSC rather than Pyomo. If we’re not running a loop, we can still update SSC only I guess this happens once for whatever Pyomo horizon is defined (this might not be a feature we keep long-term, perhaps only for
debugging).
- Inputs:
dispatch_model (Pyomo model) : solved Pyomo Dispatch model (ConcreteModel) horizon (float Quant) : length of time of horizon, whether SSC or Pyomo (in hours) N_full (int) : length of full simulation time (in hours, no Quant) run_loop (bool) : flag to determine if simulation is segmented
- Outputs:
disp_targs (dict) : dictionary of dispatch target arrays for use in SSC
- class simulations.dispatch.IndirectNuclearDispatch.IndirectNuclearDispatchParamWrap(**kwargs)[source]¶
Bases:
dispatch.NuclearDispatch.NuclearDispatchParamWrap
The NuclearDispatchParamWrap class is meant to be the staging area for the creation of Parameters ONLY for the NuclearDispatch class. It communicates with the NE2 modules, receiving SSC and PySAM input dictionaries to calculate both static parameters used for every simulation segment AND initial conditions that can be updated.
- __init__(**kwargs)[source]¶
Initializes the NuclearDispatchParamWrap module
- Inputs:
unitRegistry (pint.registry) : unique unit Pint unit registry SSC_dict (dict) : dictionary of SSC inputs needed to run modules PySAM_dict (dict) : dictionary of PySAM inputs + file names pyomo_horizon (int Quant) : length of Pyomo simulation segment (hours) dispatch_time_step (int Quant) : length of each Pyomo time step (hours)
- set_design()[source]¶
Method to calculate and save design point values of Plant operation
This method extracts values and calculates for design point parameters of our Plant (e.g., nuclear thermal power output, power cycle efficiency, inlet and outlet temperatures, etc.).
- set_indirect_config_parameters(param_dict)[source]¶
Method to set fixed costs of the Plant
This method calculates some fixed costs for the Plant operations, startup, standby, etc.
- Inputs:
param_dict (dict) : dictionary of Pyomo dispatch parameters
- Outputs:
param_dict (dict) : updated dictionary of Pyomo dispatch parameters
simulations.dispatch.NuclearDispatch module¶
Pyomo real-time dispatch model
Model authors: * Mike Wagner - UW-Madison * Bill Hamilton - NREL * John Cox - Colorado School of Mines * Alex Zolan - NREL
Pyomo code by Alex Zolan Modified by Gabriel Soto
- class simulations.dispatch.NuclearDispatch.NuclearDispatch(**kwargs)[source]¶
Bases:
dispatch.GeneralDispatch.GeneralDispatch
The NuclearDispatch class is meant to set up and run Dispatch optimization as a mixed integer linear program problem using Pyomo, specifically for the NuclearTES NE2+SSC module.
- __init__(**kwargs)[source]¶
Initializes the NuclearDispatch module
The instantiation of this class receives a parameter dictionary from the NE2 module (created using the NuclearDispatchWrapper class). It calls on the GeneralDispatch __init__ to create the model. The GeneralDispatcher first creates an empty Concrete Model from Pyomo, then generates Parameters from the parameter dictionary, Variables, Objectives and Constraints.
- Inputs:
params (dict) : dictionary of Pyomo dispatch parameters unitRegistry (pint.registry) : unique unit Pint unit registry
- addNuclearNodeLogicConstraints()[source]¶
Method to add nuclear logic constraints to the Pyomo General Model
This method adds constraints pertaining to tracking binary variable logic for the nuclear plant. Essentially, to make sure the correct modes are activated when they are allowed. There is no Nuclear standby (nor CSP) so those particular constraints are also just for completeness sake.
- addNuclearStartupConstraints()[source]¶
Method to add nuclear startup constraints to the Pyomo Nuclear Model
This method adds constraints pertaining to nuclear reactor startup within the Pyomo Nuclear Dispatch class. Several nested functions are defined. We don’t model nuclear reactor startup in SSC, this is kept for completeness’ sake. This is essentially used as a sanity check, if Pyomo deems that nuclear should shutdown or startup then something is wrong and SSC will complain.
- addNuclearSupplyAndDemandConstraints()[source]¶
Method to add nuclear supply and demand constraints to the Pyomo Nuclear Model
This method adds constraints pertaining to nuclear supply and demand energy constraints. Some constraints might be redundant, they are adapted from the CSP constraints (thanks LORE team).
- addPiecewiseLinearEfficiencyConstraints()[source]¶
Method to add efficiency constraints to the Pyomo Nuclear Model
This method adds constraints pertaining to efficiency constraints defined as a piecewise linear approximation. Also referred to as Cycle supply and demand constraints. In the NuclearDispatch, we add an extra balance of power with respect to energy storage and power produced from the nuclear reactor.
TODO: This should be revisited when adding MED!!
- addTESEnergyBalanceConstraints()[source]¶
Method to add TES constraints to the Pyomo Nuclear Model
This method adds constraints pertaining to TES energy balance from charging with thermal power and discharging to the power cycle.
TODO: revisit tes_start_up_rule -> do we need this for nuclear? TODO: do we need maintain_tes_rule?
- add_objective()[source]¶
Method to add an objective function to the Pyomo Nuclear Model
This method adds an objective function to the Pyomo Nuclear Dispatch model. Typically, the LORE team defined a nested function and passes it into the Pyomo model.
- generate_constraints(skip_parent=False)[source]¶
Method to add ALL constraints to the Pyomo Nuclear Model
This method calls the previously defined constraint methods to instantiate them and add to the existing model. This method first calls the GeneralDispatch version to set PowerCycle constraints, then calls nuclear constraint methods to add them to the model.
- generate_params(params, skip_parent=False)[source]¶
Method to generate parameters within Pyomo Nuclear Model
This method reads in a dictionary of pyomo parameters and uses these inputs to initialize parameters for the Pyomo Concrete Model. This method sets up parameters particularly for the Power Cycle. It also defines some lambda functions that helps convert Pint units to Pyomo units. It first instantiates PowerCycle parameters through GeneralDispatch, then instantiates Nuclear parameters.
Note: initial conditions are defined for the time period immediately preceding the start of this new Pyomo time segment.
- Inputs:
params (dict) : dictionary of Pyomo dispatch parameters
- generate_variables(skip_parent=False)[source]¶
Method to generate parameters within Pyomo Nuclear Model
This method instantiates variables for the Pyomo Concrete Model, with domains. Does not need initial guesses here, they are defined in the parameters. We first define continuous and binary variables for the Power Cycle through GeneralDispatch, then declare nuclear variables.
- class simulations.dispatch.NuclearDispatch.NuclearDispatchOutputs[source]¶
Bases:
object
The NuclearDispatchOutputs class is meant to handle outputs from a given, solved Pyomo Dispatch model. It returns desired outputs in appropriate formats and syntaxes for PostProcessing and linking simulation segments between Pyomo and SSC calls.
- get_dispatch_targets_from_Pyomo(horizon, N_full, run_loop=False)[source]¶
Method to set fixed costs of the Plant
This method parses through the solved Pyomo model for Dispatch optimization and extracts results that are used as Dispatch Targets in the SAME simulation segment but in SSC rather than Pyomo. If we’re not running a loop, we can still update SSC only I guess this happens once for whatever Pyomo horizon is defined (this might not be a feature we keep long-term, perhaps only for
debugging).
- Inputs:
dispatch_model (Pyomo model) : solved Pyomo Dispatch model (ConcreteModel) horizon (float Quant) : length of time of horizon, whether SSC or Pyomo (in hours) N_full (int) : length of full simulation time (in hours, no Quant) run_loop (bool) : flag to determine if simulation is segmented
- Outputs:
disp_targs (dict) : dictionary of dispatch target arrays for use in SSC
- class simulations.dispatch.NuclearDispatch.NuclearDispatchParamWrap(**kwargs)[source]¶
Bases:
dispatch.GeneralDispatch.GeneralDispatchParamWrap
The NuclearDispatchParamWrap class is meant to be the staging area for the creation of Parameters ONLY for the NuclearDispatch class. It communicates with the NE2 modules, receiving SSC and PySAM input dictionaries to calculate both static parameters used for every simulation segment AND initial conditions that can be updated.
- __init__(**kwargs)[source]¶
Initializes the NuclearDispatchParamWrap module
- Inputs:
unitRegistry (pint.registry) : unique unit Pint unit registry SSC_dict (dict) : dictionary of SSC inputs needed to run modules PySAM_dict (dict) : dictionary of PySAM inputs + file names pyomo_horizon (int Quant) : length of Pyomo simulation segment (hours) dispatch_time_step (int Quant) : length of each Pyomo time step (hours)
- set_design()[source]¶
Method to calculate and save design point values of Plant operation
This method extracts values and calculates for design point parameters of our Plant (e.g., nuclear thermal power output, power cycle efficiency, inlet and outlet temperatures, etc.).
- set_fixed_cost_parameters(param_dict, skip_parent=False)[source]¶
Method to set fixed costs of the Plant
This method calculates some fixed costs for the Plant operations, startup, standby, etc.
- Inputs:
param_dict (dict) : dictionary of Pyomo dispatch parameters
- Outputs:
param_dict (dict) : updated dictionary of Pyomo dispatch parameters
- set_initial_state(param_dict, updated_dict=None, plant=None, npts=None, skip_parent=False)[source]¶
Method to set the initial state of the Plant before Dispatch optimization
This method uses SSC data to set the initial state of the Plant before Dispatch optimization in Pyomo. This method is called in two ways: once before starting the simulation loop, in which case it only uses values from the SSC_dict portion of the given JSON script. The method is also called within the simulation loop to update the initial state parameters based on the ending conditions of the previous simulation segment (provided by SSC).
TODO: can we just input another dictionary instead of passing the full Plant?
- Inputs:
param_dict (dict) : dictionary of Pyomo dispatch parameters updated_dict (dict) : dictionary with updated SSC initial conditions from previous run plant (obj) : the full PySAM Plant object. npts (int) : length of the SSC horizon
- Outputs:
param_dict (dict) : updated dictionary of Pyomo dispatch parameters
- set_nuclear_parameters(param_dict)[source]¶
Method to set parameters specific to the Nuclear Plant for Dispatch optimization
This method calculates some parameters specific to the NuclearTES plant which are meant to be fixed throughout the simulation.
- Inputs:
param_dict (dict) : dictionary of Pyomo dispatch parameters
- Outputs:
param_dict (dict) : updated dictionary of Pyomo dispatch parameters
- set_time_series_nuclear_parameters(param_dict, updated_dict=None)[source]¶
Method to set fixed costs of the Plant for Dispatch optimization
This method calculates some time series parameters for the Plant operations, startup, standby, etc. These are NOT meant to be fixed, but updated at the beginning of every segment using the latest SSC outputs or to extract the next relevant segment of pricing arrays, efficiencies, etc.
- Inputs:
param_dict (dict) : dictionary of Pyomo dispatch parameters updated_dict (dict) : dictionary with updated SSC initial conditions from previous run
- Outputs:
param_dict (dict) : updated dictionary of Pyomo dispatch parameters
simulations.dispatch.SolarDispatch module¶
Pyomo real-time dispatch model
Model authors: * Mike Wagner - UW-Madison * Bill Hamilton - NREL * John Cox - Colorado School of Mines * Alex Zolan - NREL
Pyomo code by Alex Zolan Modified by Gabriel Soto
- class simulations.dispatch.SolarDispatch.SolarDispatch(**kwargs)[source]¶
Bases:
dispatch.IndirectNuclearDispatch.IndirectNuclearDispatch
,dispatch.NuclearDispatch.NuclearDispatch
The SolarDispatch class is meant to set up and run Dispatch optimization as a mixed integer linear program problem using Pyomo, specifically for the NuclearTES NE2+SSC module.
- __init__(**kwargs)[source]¶
Initializes the SolarDispatch module
The instantiation of this class receives a parameter dictionary from the NE2 module (created using the SolarDispatchWrapper class). It calls on the GeneralDispatch __init__ to create the model. The GeneralDispatcher first creates an empty Concrete Model from Pyomo, then generates Parameters from the parameter dictionary, Variables, Objectives and Constraints.
- Inputs:
params (dict) : dictionary of Pyomo dispatch parameters unitRegistry (pint.registry) : unique unit Pint unit registry
- addCycleStartupConstraints()[source]¶
Method to add cycle startup constraints to the Pyomo General Model
This method adds constraints pertaining to cycle startup within the Pyomo General Dispatch class. Several nested functions are defined.
- addPiecewiseLinearEfficiencyConstraints()[source]¶
Method to add efficiency constraints to the Pyomo Solar Model
This method adds constraints pertaining to efficiency constraints defined as a piecewise linear approximation. Also referred to as Cycle supply and demand constraints. In the SolarDispatch, we add an extra balance of power with respect to energy storage and power produced from the CSP plant.
TODO: This should be revisited when adding MED!!
- addReceiverNodeLogicConstraints()[source]¶
Method to add solar logic constraints to the Pyomo Solar Dispatch Model
This method adds constraints pertaining to tracking binary variable logic for the CSP. Essentially, to make sure the correct modes are activated when they are allowed.
- addReceiverStartupConstraints()[source]¶
Method to add solar startup constraints to the Pyomo Solar Model
This method adds constraints pertaining to CSP power tower startup within the Pyomo Solar Dispatch class. Several nested functions are defined.
- addReceiverSupplyAndDemandConstraints()[source]¶
Method to add CSP supply and demand constraints to the Pyomo Solar Model
This method adds constraints pertaining to solar supply and demand energy constraints.
- addTESEnergyBalanceConstraints()[source]¶
Method to add TES constraints to the Pyomo Solar Model
This method adds constraints pertaining to TES energy balance from charging with thermal power and discharging to the power cycle.
- add_objective()[source]¶
Method to add an objective function to the Pyomo Solar Model
This method adds an objective function to the Pyomo Solar Dispatch model. Typically, the LORE team defined a nested function and passes it into the Pyomo model.
- generate_constraints(skip_parent=False)[source]¶
Method to add ALL constraints to the Pyomo Solar Model
This method calls the previously defined constraint methods to instantiate them and add to the existing model. This method first calls the GeneralDispatch version to set PowerCycle constraints, then calls nuclear constraint methods to add them to the model.
- generate_params(params, skip_parent=False)[source]¶
Method to generate parameters within Pyomo Solar Model
This method reads in a dictionary of pyomo parameters and uses these inputs to initialize parameters for the Pyomo Concrete Model. This method sets up parameters particularly for the Power Cycle. It also defines some lambda functions that helps convert Pint units to Pyomo units. It first instantiates PowerCycle parameters through GeneralDispatch, then instantiates Solar parameters.
Note: initial conditions are defined for the time period immediately preceding the start of this new Pyomo time segment.
- Inputs:
params (dict) : dictionary of Pyomo dispatch parameters
- generate_variables(skip_parent=False)[source]¶
Method to generate parameters within Pyomo Solar Model
This method instantiates variables for the Pyomo Concrete Model, with domains. Does not need initial guesses here, they are defined in the parameters. We first define continuous and binary variables for the Power Cycle through GeneralDispatch, then declare nuclear variables.
- class simulations.dispatch.SolarDispatch.SolarDispatchOutputs[source]¶
Bases:
object
The SolarDispatchOutputs class is meant to handle outputs from a given, solved Pyomo Dispatch model. It returns desired outputs in appropriate formats and syntaxes for PostProcessing and linking simulation segments between Pyomo and SSC calls.
- get_dispatch_targets_from_Pyomo(horizon, N_full, run_loop=False)[source]¶
Method to set fixed costs of the Plant
This method parses through the solved Pyomo model for Dispatch optimization and extracts results that are used as Dispatch Targets in the SAME simulation segment but in SSC rather than Pyomo. If we’re not running a loop, we can still update SSC only I guess this happens once for whatever Pyomo horizon is defined (this might not be a feature we keep long-term, perhaps only for
debugging).
- Inputs:
dispatch_model (Pyomo model) : solved Pyomo Dispatch model (ConcreteModel) horizon (float Quant) : length of time of horizon, whether SSC or Pyomo (in hours) N_full (int) : length of full simulation time (in hours, no Quant) run_loop (bool) : flag to determine if simulation is segmented
- Outputs:
disp_targs (dict) : dictionary of dispatch target arrays for use in SSC
- class simulations.dispatch.SolarDispatch.SolarDispatchParamWrap(**kwargs)[source]¶
Bases:
dispatch.IndirectNuclearDispatch.IndirectNuclearDispatchParamWrap
,dispatch.NuclearDispatch.NuclearDispatchParamWrap
The SolarDispatchParamWrap class is meant to be the staging area for the creation of Parameters ONLY for the SolarDispatch class. It communicates with the NE2 modules, receiving SSC and PySAM input dictionaries to calculate both static parameters used for every simulation segment AND initial conditions that can be updated.
- __init__(**kwargs)[source]¶
Initializes the SolarDispatchParamWrap module
- Inputs:
unitRegistry (pint.registry) : unique unit Pint unit registry SSC_dict (dict) : dictionary of SSC inputs needed to run modules PySAM_dict (dict) : dictionary of PySAM inputs + file names pyomo_horizon (int Quant) : length of Pyomo simulation segment (hours) dispatch_time_step (int Quant) : length of each Pyomo time step (hours)
- set_design(skip_parent=False)[source]¶
Method to calculate and save design point values of Plant operation
This method extracts values and calculates for design point parameters of our Plant (e.g., nuclear thermal power output, power cycle efficiency, inlet and outlet temperatures, etc.).
- set_fixed_cost_parameters(param_dict)[source]¶
Method to set fixed costs of the Plant
This method calculates some fixed costs for the Plant operations, startup, standby, etc.
- Inputs:
param_dict (dict) : dictionary of Pyomo dispatch parameters
- Outputs:
param_dict (dict) : updated dictionary of Pyomo dispatch parameters
- set_initial_state(param_dict, updated_dict=None, plant=None, npts=None, skip_parent=False)[source]¶
Method to set the initial state of the Plant before Dispatch optimization
This method uses SSC data to set the initial state of the Plant before Dispatch optimization in Pyomo. This method is called in two ways: once before starting the simulation loop, in which case it only uses values from the SSC_dict portion of the given JSON script. The method is also called within the simulation loop to update the initial state parameters based on the ending conditions of the previous simulation segment (provided by SSC).
TODO: can we just input another dictionary instead of passing the full Plant?
- Inputs:
param_dict (dict) : dictionary of Pyomo dispatch parameters updated_dict (dict) : dictionary with updated SSC initial conditions from previous run plant (obj) : the full PySAM Plant object. npts (int) : length of the SSC horizon
- Outputs:
param_dict (dict) : updated dictionary of Pyomo dispatch parameters
- set_solar_parameters(param_dict)[source]¶
Method to set parameters specific to the Solar Plant for Dispatch optimization
This method calculates some parameters specific to the SolarTES plant which are meant to be fixed throughout the simulation.
- Inputs:
param_dict (dict) : dictionary of Pyomo dispatch parameters
- Outputs:
param_dict (dict) : updated dictionary of Pyomo dispatch parameters
- set_time_series_solar_parameters(param_dict, updated_dict=None)[source]¶
Method to set fixed costs of the Plant for Dispatch optimization
This method calculates some time series parameters for the Plant operations, startup, standby, etc. These are NOT meant to be fixed, but updated at the beginning of every segment using the latest SSC outputs or to extract the next relevant segment of pricing arrays, efficiencies, etc.
- Inputs:
param_dict (dict) : dictionary of Pyomo dispatch parameters updated_dict (dict) : dictionary with updated SSC initial conditions from previous run
- Outputs:
param_dict (dict) : updated dictionary of Pyomo dispatch parameters