eelib.utils.simulation_setup.helper_create_sim

Helper functions for the generation of new simulations.

Author: elenia@TUBS
Copyright 2024 elenia
This file is part of eELib, which is free software under the terms of the GNU GPL Version 3.

Module Contents

Functions

get_architecture_models(→ list[str])

Reads the list of superordinate models to connect to each other and every HEMS. This list is

create_excel_for_models(models_dict[, has_grid, ...])

Create excel with sheets for all existing models and their parameters.

read_excel_for_models(→ dict)

Create dict of model data from information in excel on all model types.

create_excel_for_same_models(model_data)

Create excel with sheets for all named models with 1 entity to possibly multiply them.

read_excel_for_same_models(→ dict)

Create dict of model data from existent data and information on same models at loadbuses.

read_profiles_from_grid(→ dict)

grid.load.profile might contain a reference to one load profile per loadbus.

create_model_data(→ dict)

Create dict for model data with information on all model parameterizations.

create_dict_from_grid(→ dict)

Create dict for grid simulations with entities at specific load buses.

create_grid_model_config(→ dict)

Create dict for connections for grid simulations with entities at specific load buses.

create_input_file(→ None)

Create full input file for simulations.

create_sim_config_str_from_model_data() → str)

Create the string for SIM_CONFIG as part of the scenario script using the entered model data.

create_sim_script(models_dict, model_names_list, sc_param)

Create and store a python script to run a configured scenario simulation.

move_files_to_testing(scenario_name, dir_input, ...)

Moves scenario files to their respective directories using pathlib.

get_architecture_models() list[str]

Reads the list of superordinate models to connect to each other and every HEMS. This list is stored in eelib/model_connections/architecture_models.json.

Raises:
  • FileNotFoundError – If the architecture models file is not found.

  • TypeError – If the content of the architecture models file is not a list.

Returns:

List of superordinate models to connect to each other and every HEMS.

Return type:

list[str]

create_excel_for_models(models_dict: dict, has_grid: bool = True, bool_same_models: bool = False, no_sheets: list = ['Forecast', 'Pandapower', 'Powerfactory'], no_params: list = ['step_size', 'n_steps'], model_data: dict[str, pandas.DataFrame] = dict())

Create excel with sheets for all existing models and their parameters.

Parameters:
  • models_dict (dict) – Info about eElib models and their parameters.

  • has_grid (bool) – Wants to place the entities in a grid.

  • bool_same_models (bool) – If models can have all the same entities. Defaults to False.

  • no_sheets (list) – Listing of all model types that do not need a sheet, because they are created differently/separately. Defaults to [“Forecast”, “Pandapower”, “Powerfactory”].

  • no_params (list) – Listing of all parameters that are not filled for the model but given otherwise (e.g. from scenario). Defaults to [“step_size”, “n_steps”].

  • model_data (dict[str, pd.DataFrame]) – Pre-filled model_data (e.g. from grid profiles) to be filled into the excel.

Raises:

ValueError – If identical parameterisation is used in combination with grid profiles.

read_excel_for_models(models_dict: dict) dict

Create dict of model data from information in excel on all model types.

Parameters:

models_dict (dict) – info about existing models and their parameters

Returns:

info on all models/entities for the simulation

Return type:

dict

create_excel_for_same_models(model_data: dict)

Create excel with sheets for all named models with 1 entity to possibly multiply them.

Parameters:

model_data (dict) – info on models for the simulation

read_excel_for_same_models(model_data: dict) dict

Create dict of model data from existent data and information on same models at loadbuses.

Parameters:

model_data (dict) – info on models for the simulation

Returns:

info on all entities for the simulation

Return type:

dict

read_profiles_from_grid(grid: pandapower.auxiliary.pandapowerNet, profile_unit: str) dict

grid.load.profile might contain a reference to one load profile per loadbus. For every profile specified in grid.load.profile, reads those profiles from grid.profiles, stores them under examples/data_input/load. In SimBench, references starting with “H” mark Households. Everything else is industrial. Despite that, everything is parameterised as a HouseholdsCSV. Alerts, when a CSVReader at that loadbus is already specified.

Parameters:
  • grid (pandapowerNet) – The grid used in the simulation.

  • profile_unit (str) – Unit of profiles stored in grid.profiles (“W”, “kW”).

Returns:

Dict in the format of model_data to update the existing model_data.

Return type:

dict

create_model_data(model_data: dict, store: bool = False) dict

Create dict for model data with information on all model parameterizations.

Parameters:
  • model_data (dict) – info on all entities for the simulation

  • store (bool) – Whether to store the config file into “model_data.json”. Defaults to False.

Returns:

model data information for the simulation

Return type:

dict

create_dict_from_grid(grid: pandapower.auxiliary.pandapowerNet | None = None, store: bool = False) dict

Create dict for grid simulations with entities at specific load buses.

Parameters:
  • grid (pandapowerNet | None) – pandapower grid object. Defaults to None.

  • store (bool) – Whether to store the config file into “grid.json”. Defaults to False.

Returns:

grid information for the simulation

Return type:

dict

create_grid_model_config(model_data: dict, grid: pandapower.auxiliary.pandapowerNet | None = None, store: bool = False) dict

Create dict for connections for grid simulations with entities at specific load buses.

Parameters:
  • model_data (dict) – info on all entities for the simulation and their loadbuses

  • grid (pandapowerNet | None) – Corresponding grid. Defaults to None.

  • store (bool) – Whether to store the config file into “grid_model_config.json”. Defaults to False.

Returns:

connection config information for the simulation

Return type:

dict

create_input_file(model_data: dict, name: str, grid: pandapower.auxiliary.pandapowerNet | None = None, grid_parameters: dict = {}, store_single_files: bool = False) None

Create full input file for simulations.

Parameters:
  • model_data (dict) – info on all entities for the simulation and their loadbuses

  • name (str) – name to store the file for, extension “.json” will be added

  • grid (pandapowerNet | None) – pandapower grid object. Defaults to None.

  • grid_parameters (dict) – information on all grid parameters

  • store_single_files (bool) – Whether to also store the information into separate files. Defaults to False.

Returns:

Returns nothing.

Return type:

None

create_sim_config_str_from_model_data(models_dict: dict, model_names_list: list, sc_parameters: eelib.data.dataclass.SimScriptConfigParams, out_attributes: dict = dict()) str

Create the string for SIM_CONFIG as part of the scenario script using the entered model data.

Parameters:
  • models_dict (dict) – information about all eELib model, including class and valid parameters

  • model_names_list (list) – listing of the names of all used models

  • sc_parameters (SimScriptConfigParams) – parameters for the scenario configuration

  • out_attributes (dict) – dict[model_name: list[attributes of this model to store in DB]]

Returns:

string representing the SIM_CONFIG part of the scenario script

Return type:

str

create_sim_script(models_dict: dict, model_names_list: list, sc_param: eelib.data.dataclass.SimScriptConfigParams, out_attributes: dict = dict())

Create and store a python script to run a configured scenario simulation.

Parameters:
  • models_dict (dict) – information about all eELib model, including class and valid parameters

  • model_names_list (list) – listing of the names of all used models

  • sc_param (SimScriptConfigParams) – parameters for the scenario configuration

  • out_attributes (dict) – dict[model_name: list[attributes of this model to store in DB]]

move_files_to_testing(scenario_name: str, dir_input: str, dir_scenario: str)

Moves scenario files to their respective directories using pathlib.

Parameters:
  • scenario_name (str) – The name of the scenario.

  • dir_input (str) – The directory to move the JSON file to.

  • dir_scenario (str) – The directory to move the Python script to.