smooth.framework package

Submodules

Run SMOOTH

This is the core of smooth. It solves (M)ILP of an energy system model for discrete time steps using the Open Energy Modelling Framework solver (oemof-solph).

How to use

The run_smooth() function expects an energy model. Such a model consists of:

  • energy sources
  • energy sinks
  • energy transformers
  • buses to transport energy

Additionally, simulation parameters are needed to run the model. A model is therefore defined as a dictionary containing all components, buses (grouped as busses) and simulation parameters (grouped as sim_params, see smooth.framework.simulation_parameters.SimulationParameters).

Example:

{
    components: {
        name_of_first_component: {
            component: ...,
            capex: ...,
            opex: ...,
            ...
        },
        ...
    },
    busses: [
        name_of_first_bus,
        name_of_second_bus,
        ...
    ],
    sim_params: {
        start_date: ...,
        n_intervals: ...,
        interval_time: ...,
        interest_rate: 0.03,
        ...
    }
}

Note

Legacy models (version < 0.2.0) define their components as a list with an extra field name for each component. This is deprecated.

Result

Two items are returned. The second is a string describing the oemof solver return status. You want this to be ‘ok’, although other values are possible. The first item returned is a list of all components, each updated with

  • sim_params: the original simulation parameters, plus date_time_index for each time step and sim_time_span in minutes

  • results: results from the simulation

    • variable_costs*
    • art_costs*
    • variable_emissions*
    • annuity_capex
    • annuity_opex
    • annuity_variable_costs
    • annuity_total
    • annual_fix_emissions
    • annual_op_emissions
    • annual_variable_emissions
    • annual_total_emissions
  • states: dictionary with component-specific attributes. Each entry is a list with values for each time step

  • flows: dictionary with each flow of this component. Key is tuple (from, to), entry is list with value for each time step

  • data: pandas dataframe

  • (component-specific attributes)

* a list with a value for each time step

Implementation

The concept of run_smooth() is demonstrated in the figure below:

run_smooth.png

Fig.1: Concept of run_smooth function.

The run_smooth() function has three distinct phases: initialization, simulation and post processing.

Initialization

There is not much to see here. Mainly, component instances get created from the model description. For legacy models (version < 0.2.0), the component list is converted to a dictionary. No oemof model is built here.

Simulation

This is the main part of the function. For each time step, an oemof model is solved and evaluated:

  1. print current time step to console if print_progress is set in parameters

  2. initialize oemof energy system model

  3. create buses

  4. update components and add them to the oemof model

  5. update bus constraints

  6. write lp file in current directory

  7. call solver for model

  8. check returned status for non#.optimal solution

  9. handle results for each component

    1. update flows
    2. update states
    3. update costs
    4. update emissions

Post-processing

After all time steps have been computed, call the generate_results function of each component. Finally, return the updated components and the last oemof status.

smooth.framework.run_smooth.run_smooth(model)

Runs the smooth simulation framework

Parameters:model (dictionary) – smooth model object containing parameters for components, simulation and busses
Returns:results of all components and oemof status
Return type:tuple of components and string
Raises:SolverNonOptimalError if oemof result is not ok and not optimal

Simulation Parameters

class smooth.framework.simulation_parameters.SimulationParameters(params)

Bases: object

Class to store parameters for smooth simulation.

Parameters:
  • start_date (string representation of date) – the first evaluated time period. Defaults to ‘1/1/2019’
  • n_intervals (integer) – number of time steps. Defaults to 24*7=168
  • interval_time (integer) – length of one time step in minutes. Defaults to 60 (one hour)
  • interest_rate (float) – Interest rate for calculating annuity out of CAPEX. Defaults to 0.03 (3%)
  • print_progress (boolean) – Decide if the running progress should be printed out. Defaults to False
  • show_debug_flag (boolean) – Decide if last result values should be shown in case solver was not successful. Defaults to True
Variables:
  • date_time_index – pandas date range of all time periods to be evaluated
  • sim_time_span – length of simulation time range in minutes
set_parameters(params)

Helper function to set simulation parameters on initialisation.

Parameters:params (dictionary) – parameters to set
Raises:ValueError for unsupported simulation parameters

Module contents