Internal functions

districtgenerator.functions.change_resolution

Script to change resolution of timeseries values with constant sampling rate.

districtgenerator.functions.change_resolution.changeResolution(values, oldResolution, newResolution, method='mean')[source]

Changes the temporal resolution of a time series with constant sampling intervals.


Parameters

  • values: Array-like, the original time series data to be resampled.

  • oldResolution: Integer, original time step in seconds (e.g. 3600 for hourly data).

  • newResolution: Integer, desired time step in seconds after resampling.

  • method: {“mean”, “sum”}, optional. Determines how resampling is handled:
    • “mean”: Averages values when increasing time step (e.g. for power).

    • “sum”: Sums values when increasing time step (e.g. for energy). Default is “mean”.

Returns

  • valuesResampled: Array of resampled values at the new resolution.

districtgenerator.functions.dhw_stochastical

Script to generate domestic hot water demands. This script is a copy of dhw_stochastical.py from pyCity. https://github.com/RWTH-EBC/pyCity

districtgenerator.functions.dhw_stochastical.compute_daily_demand(probability_profiles, average_profile, occupancy, current_day, temperature_difference=35)[source]

Computes the daily domestic hot water (DHW) usage and corresponding heat demand based on occupancy and stochastic probability profiles.


Parameters

  • probability_profiles: Dictionary of minute-wise sampled probability distributions for different occupancy levels.

  • average_profile: Array of average tap water demand (liters/hour) per minute of the day.

  • occupancy: Array of 10-minute sampled occupancy values for the building/apartment.

  • current_day: Integer representing the current day of the year (0 = Jan 1).

  • temperature_difference: Float or array indicating the temperature rise required [°C] (default is 35°C).

Returns

  • water: Array of minute-wise tap water volume flow in liters/hour.

  • heat: Array of minute-wise heat demand in Watts based on water usage.

districtgenerator.functions.dhw_stochastical.full_year_computation(occupancy, profiles, time_dis=3600, initial_day=0, temperature_difference=35)[source]

Computes a full year of domestic hot water (DHW) usage and heat demand based on occupancy and stochastic profiles.


Parameters

  • occupancy: Array-like, 10-minute sampled occupancy values for the entire year.

  • profiles: Dictionary containing probability and average demand profiles for weekdays (wd) and weekends (we) by occupancy level.

  • time_dis: Integer, time discretization of the output data in seconds (default is 3600 seconds).

  • initial_day: Integer representing the first day of the year (0 = Monday, 6 = Sunday).

  • temperature_difference: Float or array indicating the temperature rise required [°C] (default is 35°C).

Returns

  • water: Array of tap water flow in liters/hour, resampled to the specified time resolution.

  • heat: Array of heat demand in Watts, resampled to the specified time resolution.

districtgenerator.functions.dhw_stochastical.load_profiles(filename)[source]

Loads domestic hot water (DHW) usage profiles from an Excel file and structures them by day type and occupancy level.


Parameters

  • filename: Path to the Excel file containing water demand profiles. The file must include sheets named for weekday (wd) and weekend (we) profiles, both average and probability-based.

Returns

  • profiles: Dictionary containing structured demand profiles. Includes:

    • ‘wd’: Weekday probability profiles by occupancy count.

    • ‘we’: Weekend probability profiles by occupancy count.

    • ‘wd_mw’ and ‘we_mw’: Average minute-wise water usage profiles for weekdays and weekends.

districtgenerator.functions.heating_profile_5R1C

Script to generate heating and cooling demands sccording to DIN EN ISO 13790.

districtgenerator.functions.heating_profile_5R1C.calc(zoneParameters, zoneInputs, T_m_init, TCoolingSet, THeatingSet)[source]

Calculates heating and cooling demand over time based on indoor comfort targets and thermal zone properties.


Parameters

  • zoneParameters: Object containing thermal zone parameters (resistances, capacities, etc.).

  • zoneInputs: Object containing environmental and internal gains (solar radiation, internal heat, etc.).

  • T_m_init: Initial temperature of the thermal mass [°C].

  • TCoolingSet: Array of cooling setpoint temperatures [°C] for each timestep.

  • THeatingSet: Array of heating setpoint temperatures [°C] for each timestep.

Returns

  • Q_H: Array of heating demand per timestep [W].

  • Q_C: Array of cooling demand per timestep [W].

  • T_op: Array of operative temperatures [°C].

  • T_m: Array of thermal mass temperatures [°C].

  • T_i: Array of air temperatures [°C].

  • T_s: Array of surface temperatures [°C].

districtgenerator.functions.heating_profile_5R1C.calculate(zoneParameters, T_e, dt)[source]

Calculates heating or cooling demand based on simplified 5R1C thermal model using DIN EN ISO 13790.


Parameters

  • zoneParameters: Object containing thermal zone characteristics such as resistances, capacities, and gains.

  • T_e: Array of external temperatures [°C] for each timestep.

  • dt: Time step duration in hours.

Returns

  • Q_HC: Array of heating or cooling power required [W] at each timestep.

  • T_i: Array of air temperatures [°C].

  • T_s: Array of surface temperatures [°C].

  • T_m: Array of thermal mass temperatures [°C].

  • T_op: Array of operative temperatures [°C].