uesgraphs.teaser_integration package

Submodules

uesgraphs.teaser_integration.simulate module

Module to control multiprocessing of simulation of TEASER buildings.

You need to set a couple of environment variables for you conda environment to use this module:

PYTHONPATH

uesgraphs.teaser_integration.simulate.set_up_terminal_logger(name: str, level: int = 20) Logger[source]

Set up a simple console-only logger for small functions.

Parameters:
  • name – Logger name

  • level – Logging level (default: INFO)

Returns:

Configured console logger

class uesgraphs.teaser_integration.simulate.WorkerSimulation(sim_function, sim_part, prj, model_path, results_path, start_time, stop_time, output_interval, method, tolerance, process_number, result_queue, aixlib_path)[source]

Bases: Process

Helper class to enable simulation in a JoinableQueue.

This class inherits from multiprocessing.Proccess. Pass over your simulation function and all parameters that are necessary for this function.

Parameters:
  • sim_function (simulate() function) –

  • sim_part (Django QuerySet, NumPy Array or any other iterable) – Iterable collection of BuildingEnergy objects

  • prj (Scenario instance) – Scenario instance of the buildings that are simulated. Please ensure if you are using multiprocessing that all buildings are within the same prj.

  • model_path (str) – Path where Modelica model from TEASER is located. This is TEASER output path.

  • results_path (str) – Path where Dymola results should be stored.

  • start_time (int) – Start time of the simulation

  • stop_time (int) – Stop time of the simulation

  • output_interval (int) – Output interval of the simulation

  • solver (string) – Used solver in Dymola. All Dymola solvers are supported(default: ‘Dassl’

  • tolerance (float) – Tolerance of used solver

  • process_number (int) – Counter of parallel processes, if multiprocessing is used. Default is None which indicates that no multuprocessing is used. Otherwise please set an individual number for every process that is used.

  • result_queue (multiprocessing.JoinableQueue()) – JoinableQueue instance for each worker.

__init__(sim_function, sim_part, prj, model_path, results_path, start_time, stop_time, output_interval, method, tolerance, process_number, result_queue, aixlib_path)[source]

Init function of WorkerSimulation.

run()[source]

Run the specified simulation function with all parameters.

uesgraphs.teaser_integration.simulate.simulate(sim_part, prj, model_path, results_path, start_time, stop_time, output_interval, method, tolerance, process_number, aixlib_path)[source]

Simulate building models in serial using Dymola.

This function simulates all buidlings given in the building_query_set in serial(one after another). This function can be used for parallel processing of simulation. There are no default values because it caused trouble with multiprocessing.

Note: Please ensure that for all buildings corresponding models have been generated. Also ensure that all models are within the same prj, otherwise this will neither work for single nor for multiprocessing.

Parameters:
  • sim_part (any iterable) – Iterable collection of Building objects

  • prj (Scenario instance) – Scenario instance of the buildings that are simulated. Please ensure if you are using multiprocessing that all buildings are within the same prj.

  • model_path (str) – Path where Modelica model from TEASER is located. This is TEASER output path.

  • results_path (str) – Path where Dymola results should be stored.

  • start_time (int) – Start time of the simulation

  • stop_time (int) – Stop time of the simulation

  • output_interval (int) – Output interval of the simulation

  • solver (string) – Used solver in Dymola. All Dymola solvers are supported(default: ‘Dassl’

  • tolerance (float) – Tolerance of used solver

  • process_number (int) – Counter of parallel processes, if multiprocessing is used. Default is None which indicates that no multuprocessing is used. Otherwise please set an individual number for every process that is used.

uesgraphs.teaser_integration.simulate.queue_simulation(sim_function, prj, number_of_workers=3, model_path='/home/runner/TEASEROutput', results_path='/home/runner/djangoteaserout', start_time=0.0, stop_time=31532400.0, output_interval=3600.0, method='Dassl', tolerance=0.0001, aixlib_path=None)[source]

Simulate multiple buildings in a JoinableQueue.

This function simulates all buidlings given in the building_query_set. It uses JoinableQueue for multiprocessing.

Note: Please ensure that for all buildings corresponding models have been generated. Also ensure that all models are within the same prj, otherwise this will neither work for single nor for multiprocessing.

Parameters:
  • sim_function (simulate() function) –

  • prj (Scenario instance) – Scenario instance of the buildings that are simulated. Please ensure if you are using multiprocessing that all buildings are within the same prj.

  • number_of_workers (int) – Number of workers used for the simulation. (default: number of physical processors - 1)

  • model_path (str) – Path where Modelica model from TEASER is located. This is TEASER output path.

  • results_path (str) – Path where Dymola results should be stored.

  • start_time (int) – Start time of the simulation

  • stop_time (int) – Stop time of the simulation

  • output_interval (int) – Output interval of the simulation

  • solver (string) – Used solver in Dymola. All Dymola solvers are supported(default: ‘Dassl’

  • tolerance (float) – Tolerance of used solver

uesgraphs.teaser_integration.utilities module

This module includes TEASER for the demand estimation based on the .geojson

uesgraphs.teaser_integration.utilities.set_up_file_logger(name: str, log_dir: str | None = None, level: int = 40) Logger[source]

Set up a full file+console logger for major functions.

Parameters:
  • name – Logger name

  • log_dir – Directory for log files (default: temp directory)

  • level – Logging level (default: ERROR)

Returns:

Configured file+console logger

uesgraphs.teaser_integration.utilities.set_up_logger(name, log_dir=None, level=40)[source]

Sets up a configured logger with file handler.

Creates a logger with specified name and logging level. Log files are stored in a directory with timestamp in filename. If no directory is specified, the system’s temporary directory is used.

Parameters:
  • name (str) – Name of the logger, also used for filename

  • log_dir (str, optional) – Directory for log files. Defaults to None (uses temp directory)

  • level (int, optional) – Logging level (e.g. logging.ERROR, logging.INFO). Defaults to logging.ERROR

Returns:

Configured logger object

Return type:

logging.Logger

Example

>>> logger = set_up_logger("my_app", "/var/log", logging.INFO)
>>> logger.info("Application started")

Notes

  • Log filename format: {name}_{YYYYMMDD_HHMMSS}.log

  • Log entry format: time - logger_name - [file:line] - level - message

uesgraphs.teaser_integration.utilities.load_simulation_settings_from_excel(excel_path, logger=None)[source]

Load simulation settings from Excel ‘Simulation’ sheet.

Parameters:
  • excel_path (str or Path) – Path to Excel file containing simulation settings

  • logger (logging.Logger, optional) – Logger instance

Returns:

sim_params – Dictionary of simulation parameters

Return type:

dict

Raises:

ValueError – If required simulation parameters are missing

uesgraphs.teaser_integration.utilities.load_component_parameters(excel_path, component_type)[source]

Load component parameters from an Excel file.

Reads a specific sheet from an Excel file and returns parameters as a dictionary. Expected Excel structure: - Column A: Parameter (parameter names) - Column B: Value (parameter values)

Parameters:
  • excel_path (str or Path) – Path to the Excel file containing component parameters

  • component_type (str) – Type of component, must be one of: ‘pipes’, ‘supply’, ‘demands’, ‘simulation’ This determines which sheet to read from the Excel file

Returns:

Dictionary with parameter names as keys and their values Returns empty dict if sheet not found

Return type:

dict

Raises:
  • FileNotFoundError – If the Excel file does not exist

  • ValueError – If the component_type is not valid or Excel structure is incorrect

Examples

>>> params = load_component_parameters('parameters.xlsx', 'pipes')
>>> print(params['dp_nominal'])
0.10
uesgraphs.teaser_integration.utilities.create_project()[source]

Create a TEASER project for current version.

uesgraphs.teaser_integration.utilities.create_district(info_path, prj, logger=None)[source]

Create TEASER buildings using modern API, according to infos in geojson.

Parameters:
  • info_path (path) – Full path to json with building infos.

  • district_name (string) – Name of district

  • prj (TEASER project) – Project class where buildings should be added to.

uesgraphs.teaser_integration.utilities.read_results(prj, buildings, signals, index, stop_time, timestep, results_path=None, csv_path=None, indoor_air=False, logger=None)[source]

Read simulation data from .mat file and save them into csv.

Reads Dymola result files and saves them as time series in csv. Naming convention of time series follows proposed naming schema of Team GA. It assumes that all thermal_zones in PostgreSQL database are modeled as a thermal zone in Modelica. Thus this approach is not yet ready to be used with archetypes.

Parameters:
  • prj (TEASER Project() instance) – TEASER Project with all buildings that have been simulated. Names need to be identical.

  • buidlings (list) – List of buildings whose results should be read.

  • signals (list) – List of signals to be read from the results file.

  • index (Pandas date_range) – Pandas date range of the simulation data. Must fit the length of simulation data. (default: hourly for year 2015)

  • results_path (str) – Path where Dymola results are stored.

  • csv_path (str) – Path where csv results should be stored.

  • indoor_air (boolean) – If true, output csv-file contains dataframe with one column for each given signal. If false, Heater and Cooler signals are expected and seperate output csv-files are created for both signals.

uesgraphs.teaser_integration.utilities.run_sim_teaser(buildings_info_path, save_path, weather_path=None, timestep=3600, stop_time=31536000, sim_setup_path=None, logger=None, log_level=10, number_of_workers=None)[source]

Run TEASER simulations for demand estimation based on building information from a .geojson file.

Parameters:

buildings_info_pathstr

The path to the .geojson file containing building information for TEASER model creation.

save_pathstr or Path

Directory path where the resulting demand CSV files will be saved.

weather_pathstr, optional

The path to the weather file (.mos) to be used in the simulation. If not provided, a default weather file will be used.

timestepint, optinal

Simulation timestep in seconds (default is 3600 for hourly data)

stop_timeint, optional

Total simulation time in seconds (default is 8760*3600 for one year of hourly data)

sim_setup_pathstr or Path, optional

Path to the simulation setup for timestep and stop time. If not provided, default values will be used.

loggerlogging.Logger, optional

Logger instance. If None, creates a new file logger in temp directory

log_levelint, optional

Logging level (default is logging.DEBUG). Only used if logger is None

number_of_workersint, optional

Number of parallel workers for simulation. If None, it will be set to (number of CPU cores - 4) to avoid overloading the system.

Returns:

tuple

Paths to the generated demand CSV files: (heating_demand_csv, cooling_demand_csv)