energy_demand package

Subpackages

Submodules

energy_demand.enduse_func module

Enduse

Contains the Enduse Class. This is the most important class where the change in enduse specific energy demand is simulated depending on scenaric assumptions.

class energy_demand.enduse_func.Enduse(region_name, scenario_data, lookups, assumptions, non_regional_lp_stock, sim_param, enduse, sector, fuel, tech_stock, heating_factor_y, cooling_factor_y, fuel_switches, service_switches, fuel_tech_p_by, tech_increased_service, tech_decreased_share, tech_constant_share, installed_tech, sig_param_tech, enduse_overall_change, regional_lp_stock, dw_stock=False, reg_scen_drivers=None, crit_flat_profile=False)[source]

Bases: object

Enduse Class (Residential, Service and Industry)

For every region and sector, a different instance is generated. In this class, first the change in energy demand is calculated on a yearls temporal scale. Calculations are performed in a cascade (e.g. first reducing climate change induced savings, then substracting further behavioural savings etc.). After yearly calculations, the demand is converted to hourly demand.

Also within this function, the fuel inputs are converted to energy service (short: service) and later on converted back to fuel demand.

Parameters:
  • region_name (str) – Region name
  • scenario_data (dict) – Scenario data
  • lookups (dict) – Lookups
  • assumptions (dict) – Assumptions
  • non_regional_lp_stock (dict) – Load profile stock
  • sim_param (dict) – Simulation parameter
  • enduse (str) – Enduse name
  • sector (str) – Sector name
  • fuel (array) – Yearly fuel data for different fueltypes
  • tech_stock (object) – Technology stock of region
  • heating_factor_y (array) – Distribution of fuel within year to days (yd) (directly correlates with HDD)
  • cooling_factor_y (array) – Distribution of fuel within year to days (yd) (directly correlates with CDD)
  • fuel_switches (list) – Fuel switches
  • service_switches (list) – Service switches
  • fuel_tech_p_by (dict) – Fuel tech assumtions in base year
  • tech_increased_service (dict) – Technologies per enduse with increased service due to scenarios
  • tech_decreased_share (dict) – Technologies per enduse with decreased service due to scenarios
  • tech_constant_share (dict) – Technologies per enduse with constat service
  • installed_tech (dict) – Installed technologes for this enduse
  • sig_param_tech (dict) – Sigmoid parameters
  • enduse_overall_change (dict) – Assumptions related to overal change in endyear
  • regional_lp_stock (object) – Load profile stock
  • dw_stock (object,default=False) – Dwelling stock
  • reg_scen_drivers (bool,default=None) – Scenario drivers per enduse
  • crit_flat_profile (bool,default=False) – Criteria of enduse has a flat shape or not

Note

  • Load profiles are assigned independently of the fueltype, i.e. the same profiles are assumed to hold true across different fueltypes
  • self.fuel_new_y is always overwritten in the cascade of calculations

Warning

Not all enduses have technologies assigned. Load peaks are derived from techstock in case technologies are defined. Otherwise enduse load profiles are used.

crit_flat_profile = None

if region_name == ‘E06000053’ – print(fuel) print(scenario_data) prnt(”;”)

energy_demand.enduse_func.apply_climate_change(enduse, fuel_new_y, cooling_factor_y, heating_factor_y, assumptions)[source]

Change fuel demand for heat and cooling service depending on changes in HDD and CDD within a region (e.g. climate change induced)

enduse : str
Enduse
fuel_new_y : array
Yearly fuel per fueltype
cooling_factor_y : array
Distribution of fuel within year to days (yd)
heating_factor_y : array
Distribution of fuel within year to days (yd)
assumptions : dict
Assumptions
Returns:fuel_new_y – Changed yearly fuel per fueltype
Return type:array

Note

  • cooling_factor_y and heating_factor_y are based on the sum
    over the year. Therefore it is assumed that fuel correlates directly with HDD or CDD.
energy_demand.enduse_func.apply_heat_recovery(enduse, assumptions, service, crit_dict, base_sim_param)[source]

Reduce heating demand according to assumption on heat reuse

Parameters:
  • assumptions (dict) – Assumptions
  • service (dict or array) – Service of current year
  • crit_dict (str) – Criteria to run function differently
  • base_sim_param (dict) – Base simulation parameters
Returns:

service_reduced – Reduced service after assumption on reuse

Return type:

dict or array

Note

A standard sigmoid diffusion is assumed from base year to end year

energy_demand.enduse_func.apply_scenario_drivers(enduse, fuel_y, dw_stock, region_name, gva, population, reg_scen_drivers, base_sim_param)[source]

The fuel data for every end use are multiplied with respective scenario drivers. If no dwelling specific scenario driver is found, the identical fuel is returned.

Parameters:
  • enduse (str) – Enduse
  • fuel_y (array) – Yearly fuel per fueltype
  • dw_stock (object) – Dwelling stock
  • region_name (str) – Region name
  • data (dict) – Data container
  • reg_scen_drivers (dict) – Scenario drivers per enduse
  • base_sim_param (dict) – Base simulation parameters
Returns:

fuel_y – Changed yearly fuel per fueltype

Return type:

array

energy_demand.enduse_func.apply_smart_metering(enduse, fuel_y, smart_meter_assump, base_sim_param)[source]

Calculate fuel savings depending on smart meter penetration

Parameters:
  • enduse (str) – Enduse
  • fuel_y (array) – Yearly fuel per fueltype
  • smart_meter_assump (dict) – smart meter assumptions
  • base_sim_param (dict) – Base simulation parameters
Returns:

fuel_y – New fuel per year

Return type:

array

Note

  • The smart meter penetration is assumed with a sigmoid diffusion.
  • In the assumptions the maximum penetration and also the
    generally fuel savings for each enduse can be defined.
energy_demand.enduse_func.apply_specific_change(enduse, fuel_y, enduse_overall_change, yr_until_changed, sim_param)[source]

Calculates fuel based on assumed overall enduse specific fuel consumption changes

Parameters:
  • enduse (str) – Enduse
  • fuel_y (array) – Yearly fuel per fueltype
  • assumptions (dict) – Assumptions
  • sim_param (dict) – Base simulation parameters
Returns:

fuel_y – Yearly new fuels

Return type:

array

Note

  • Because for enduses where no technology stock is defined (and may consist of many different) technologies, a linear diffusion is suggested to best represent multiple sigmoid efficiency improvements of individual technologies.
  • The changes are assumed across all fueltypes.
  • Either a sigmoid standard diffusion or linear diffusion can be implemented. inear is suggested.
energy_demand.enduse_func.assign_lp_no_techs(enduse, sector, load_profiles, fuel_new_y)[source]

Assign load profiles for an enduse which has not technologies defined.

Parameters:
  • enduse (str) – Enduse
  • sector (str) – Enduse
  • load_profiles (obj) – Load profiles
  • fuel_new_y (array) – Fuels
energy_demand.enduse_func.calc_fuel_tech_y(enduse, tech_stock, fuel_tech_y, lookups, mode_constrained)[source]

Calculate yearly fuel per technology (no load profile assigned).

Parameters:
  • tech_stock (object) – Technology stock
  • fuel_tech_y (dict) – Fuel per technology per year
  • lookups (dict) – look-up
  • mode_constrained (bool) – Running mode
Returns:

fuel_y – Fuel per year per fueltype

Return type:

array

Note

This function can be run in two different modes

energy_demand.enduse_func.calc_fuel_tech_yh(enduse, sector, enduse_techs, enduse_fuel_tech, tech_stock, load_profiles, lookups, mode_constrained, model_yeardays_nrs)[source]

Iterate fuels for each technology and assign shape yd and yh shape

Parameters:
  • enduse_fuel_tech (dict) – Fuel per technology in enduse
  • tech_stock (object) – Technologies
  • load_profiles (object) – Load profiles
  • lookups (dict) – Fuel look-up table
  • mode_constrained (bool) – Mode criteria
  • model_yeardays_nrs (int) – Number of modelled days
Returns:

fuels_yh – Fueltype storing hourly fuel for every fueltype (fueltype, model_yeardays_nrs, 24)

Return type:

array

energy_demand.enduse_func.calc_lf_improvement(enduse, base_yr, curr_yr, loadfactor_yd_cy, lf_improvement_ey, yr_until_changed)[source]

Calculate lf improvement depending on linear diffusion

Test if lager than zero –> replace by one

energy_demand.enduse_func.calc_peak_tech_dh(enduse, sector, enduse_techs, enduse_fuel_tech, fuel_yh, tech_stock, load_profile, lookups)[source]

Calculate peak demand for every fueltype

Parameters:
  • assumptions (array) – Assumptions
  • enduse_fuel_tech (array) – Fuel per enduse and technology
  • tech_stock (data) – Technology stock
  • load_profile (object) – Load profile
Returns:

fuels_peak_dh – Peak values for peak day for every fueltype

Return type:

array

Note

  • This function gets the hourly values of the peak day for every fueltype.
    The daily fuel is converted to dh for each technology.
  • For some technology types (heat_pump and hybrid)
    the dh peak day profile is not read in from technology stock but from shape_yh of peak day (hybrid technologies).
energy_demand.enduse_func.convert_service_tech_to_p(service)[source]

Convert service per technology to share of service within fueltype (per fueltype sum == 1.0)

Parameters:service (dict) – Service per fueltype and technology
Returns:out_dict – Service as a percentage of each technology per fueltype
Return type:dict
energy_demand.enduse_func.convert_service_to_p(tot_service_y, service_fueltype_tech)[source]

Calculate fraction of service for every technology of total service

Parameters:
  • tot_service_y (float) – Total yearly service
  • service_fueltype_tech (dict) – Service per technology and fueltype
Returns:

service_tech_p – All tecnology services are provided as a fraction of total service

Return type:

dict

Note

Iterate over values in dict and apply calculations

energy_demand.enduse_func.fuel_switch(enduse, installed_tech, sig_param_tech, tot_service_yh_cy, service_tech, service_fueltype_tech_cy_p, service_fueltype_cy_p, fuel_switches, fuel_tech_p_by, curr_yr)[source]

Calulation of service by considering fuel switch assumptions. Based on assumptions about shares of fuels which are switched per enduse to specific technologies, the installed technologies are used to calculate the new service demand after switching fuel shares.

Parameters:
  • enduse (str) – Enduse
  • installed_tech (dict) – Technologies installed
  • sig_param_tech (dict) – Sigmoid diffusion parameters
  • tot_service_yh_cy (dict) – Total regional service for every hour for base year
  • service_tech (dict) – Service for every fueltype and technology
  • service_fueltype_tech_cy_p (dict) – Fraction of service per fueltype, technology for current year
  • service_fueltype_cy_p (dict) – Fraction of service per fueltype in current year
  • fuel_switches (dict) – Fuel switches
  • fuel_tech_p_by (dict) – Fuel tech assumtions in base year
  • curr_yr (int) – Current year
Returns:

service_tech_switched – Containing all service for each technology on a hourly basis

Return type:

dict

energy_demand.enduse_func.fuel_to_service(enduse, fuel_new_y, enduse_techs, fuel_tech_p_by, tech_stock, lu_fueltypes, mode_constrained)[source]

Converts fuel to energy service (1), calcualates contribution service fraction (2)

Parameters:
  • fuel_tech_p_by (dict) – Fuel composition of base year for every fueltype for each enduse (assumtions for national scale)
  • tech_stock (object) – Technology stock of region
  • lu_fueltypes (dict) – Fueltype look-up
  • load_profiles (object) – Load profiles
  • mode_constrained (bool) – Criteria about mode
Returns:

  • tot_service_yh (array) – Absolute total yh energy service per technology and fueltype
  • service_tech (dict) – Absolute energy service for every technology
  • service_tech_p (dict) – Fraction of energy service for every technology (sums up to one in total (not specified by fueltype))
  • service_fueltype_tech_p (dict) – Fraction of energy service per fueltype and technology (within every fueltype sums up to one)
  • service_fueltype_p (dict) – Fraction of service per fueltype (within every fueltype sums up to one)

Note

(1) Calculate energy service of each technology based on assumptions about base year fuel shares of an enduse (fuel_tech_p_by).

(2) The fraction of an invidual technology to which it contributes to total energy service (e.g. how much of total heat service is provided by boiler technology).

  • Efficiency changes of technologis are considered.
  • Energy service = fuel * efficiency
  • This function can be run in two modes, depending on mode_constrained criteria
  • The base year efficiency is taken because the actual service can only be calculated with base year. Otherwise, the service would increase e.g. if technologies would become more efficient. Efficiencies are only considered if converting back to fuel However, the self.fuel_new_y is taken because the actual service was reduced e.g. due to smart meters or temperatur changes
energy_demand.enduse_func.get_crit_switch(enduse, fuelswitches, sim_param, mode_constrained)[source]

Test whether there is a switch (service or fuel)

Parameters:
  • fuelswitches (dict) – All fuel switches
  • sim_param (float) – Base Arguments
  • mode_constrained (bool) – Mode criteria

Note

If base year, no switches are implemented

energy_demand.enduse_func.get_enduse_configuration(enduse, assumptions, sim_param, fuel_switches, service_switches)[source]

Get enduse specific configuration

energy_demand.enduse_func.get_enduse_tech(fuel_tech_p_by)[source]

Get all defined technologies of an enduse

Parameters:fuel_tech_p_by (dict) – Percentage of fuel per enduse per technology
Returns:enduse_techs – All technologies
Return type:list

Note

All technologies are read out, including those which are potentiall defined in fuel or service switches.

If for an enduse a dummy technology is defined, the technologies of an enduse are set to an empty list.

Warning

For every enduse technologes must either be defined for no fueltype or for all fueltypes

energy_demand.enduse_func.get_lp_stock(enduse, non_regional_lp_stock, regional_lp_stock)[source]

Defines the load profile stock depending on enduse. (Get regional or non-regional load profile data)

Parameters:
  • enduse (str) – Enduse
  • non_regional_lp_stock (object) – Non regional dependent load profiles
  • regional_lp_stock (object) – Regional dependent load profiles
Returns:

load_profiles – Load profile

Return type:

object

Note

Because for some enduses the load profiles depend on the region they are stored in the WeatherRegion Class. One such example is heating. If the enduse is not dependent on the region, the same load profile can be used for all regions

If the enduse depends on regional factors, regional_lp_stock is returned. Otherwise, non-regional load profiles which can be applied for all regions is used (non_regional_lp_stock)

energy_demand.enduse_func.get_peak_day(fuel_yh)[source]

Iterate yh and get day with highes fuel (across all fueltypes)

Returns:peak_day_nr – Day with most fuel or service across all fueltypes
Return type:int

Note

  • The day with most fuel across all fueltypes is

considered to be the peak day - The Peak day may change date in a year

energy_demand.enduse_func.get_running_mode(enduse, mode_constrained, enduse_space_heating)[source]

Check which mode needs to be run for an enduse

Parameters:
  • mode_constrained (bool) – Criteria of running mode
  • enduse_space_heating (dict) – All heating enduses across all models
Returns:

bool – The return value

Return type:

bool

Note

If ‘crit_mode’ == True, then overall heat is provided to the supply model not specified for technologies. Otherwise, heat demand is supplied per technology

energy_demand.enduse_func.get_service_diffusion(enduse, tech_increased_service, sig_param_tech, curr_yr)[source]

Calculate energy service fraction of technologies with increased service for current year based on sigmoid diffusion

Parameters:
  • enduse (str) – Enduse
  • tech_increased_service (dict) – All technologies per enduse with increased future service share
  • sig_param_tech (dict) – Sigmoid diffusion parameters
  • curr_yr (dict) – Current year
Returns:

service_tech – Share of service per technology of current year

Return type:

dict

energy_demand.enduse_func.service_switch(enduse, tot_service_yh_cy, service_tech_by_p, tech_increase_service, tech_decrease_service, tech_constant_service, sig_param_tech, curr_yr)[source]

Apply change in service depending on defined service switches.

tot_service_yh_cy : array
Hourly service of all technologies
service_tech_by_p : dict
Fraction of service per technology
tech_increase_service : dict
Technologies with increased service
tech_decrease_service : dict
Technologies with decreased service
tech_constant_service : dict
Technologies with constant service
sig_param_tech : dict
Sigmoid diffusion parameters
curr_yr : int
Current year
Returns:service_tech_yh_cy – Service per technology in current year after switch for every hour in a year
Return type:dict

Note

The service which is fulfilled by new technologies is substracted of the replaced technologies proportionally to the base year distribution of these technologies

energy_demand.enduse_func.service_to_fuel(enduse, service_tech, tech_stock, lookups, mode_constrained)[source]

Convert yearly energy service to yearly fuel demand. For every technology the service is taken and converted to fuel based on efficiency of current year

service_tech : dict
Service per fueltype and technology
tech_stock : object
Technological stock
lookups : dict
look-up
mode_constrained : bool
Mode running criteria
Returns:fuel_per_tech – Fuel per technology Convert annaul service to fuel per fueltype for each technology
Return type:dict

Note

  • The attribute ‘fuel_new_y’ is updated
  • Fuel = Energy service / efficiency

energy_demand.energy_model module

Energy Model

The main function executing all the submodels of the energy demand model

class energy_demand.energy_model.EnergyModel(region_names, data)[source]

Bases: object

EnergyModel of a simulation yearly run

Parameters:
  • region_names (list) – Region names
  • data (dict) – Main data dictionary

Note

  • All submodels are executed here
  • All aggregation functions of the results are exectued here
energy_demand.energy_model.fuel_aggr(input_array, attribute_to_get, sector_models, sum_crit, model_yearhours_nrs, model_yeardays_nrs, region_name=False)[source]

Collect hourly data from all regions and sum across all fuel types and enduses

Parameters:
  • attribute_to_get (str) – Attribue to summarise
  • sector_models (list of list of Enduse) – Enduse objects to summarise
  • sum_crit (lp_crit,) – Criteria
  • region_name (str) – Name of region
Returns:

input_array – Summarised array

Return type:

array

energy_demand.energy_model.fuel_regions_fueltype(fuel_fueltype_regions, lookups, region_name, array_region_nr, model_yearhours_nrs, model_yeardays_nrs, all_submodels)[source]

Collect fuels for every fueltype and region (unconstrained mode). The regions are stored in an array for every timestep

Parameters:
  • lookups (dict) – Lookup container
  • region_names (list) – All region names
  • array_region_nr (int) – Array nr position of region to store results

Example

{‘final_electricity_demand’: np.array((regions, model_yearhours_nrs)), dtype=float}

energy_demand.energy_model.get_fuels_yh(enduse_object, attribute_to_get, model_yearhours_nrs, model_yeardays_nrs)[source]

Assign yh shape for enduses with flat load profiles

Parameters:
  • model_object (dict) – Object of submodel run
  • attribute_to_get (str) – Attribute to read out
Returns:

fuels – Fuels with flat load profile

Return type:

array

Note

  • For enduses where ‘crit_flat_profile’ in Enduse Class is True a flat load profile is generated. Otherwise, the yh as calculated for each enduse is used
  • Flat shape
energy_demand.energy_model.industry_submodel(region, data, enduse_names, sector_names)[source]

Industry subsector model

Parameters:
  • data (dict) – Data containter
  • enduses (list) – Enduses of industry submodel
  • sectors (list) – Sectors of industry submodel
Returns:

submodules – Submodule objects

Return type:

list

energy_demand.energy_model.residential_submodel(region, data, enduse_names, sector_names=False)[source]

Create the residential submodules (per enduse and region) and add them to list

Parameters:
  • data (dict) – Data container
  • enduse_names (list) – All residential enduses
  • sector_names (list, default=False) – Sectors
Returns:

submodule_list – List with submodules

Return type:

list

energy_demand.energy_model.service_submodel(region, data, enduse_names, sector_names)[source]

Create the service submodules per enduse, sector and region and add to list

Parameters:
  • data (dict) – Data container
  • enduse_names (list) – All residential enduses
  • sector_names (list) – Service sectors
Returns:

submodels – List with submodels

Return type:

list

energy_demand.energy_model.simulate_region(region_name, data, weather_regions)[source]

Run submodels for a single region, return aggregate results

Parameters:
  • region_name (str) – Region name
  • data (dict) – Data container
  • weather_regions (oject) – Weather regions
Returns:

region_submodels – All submodel objects

Return type:

list

energy_demand.energy_model.sum_enduse_all_regions(input_dict, attribute_to_get, sector_models, model_yearhours_nrs, model_yeardays_nrs)[source]

Summarise an enduse attribute across all regions

Parameters:
  • attribute_to_get (string) – Enduse attribute to summarise
  • sector_models (List) – List with sector models
Returns:

enduse_dict – Summarise enduses across all regions

Return type:

dict

energy_demand.main module

Energy Demand Model

  • run in constrained mode
  • run with same weather shape and same fuel input –> flat line expected
  • Test why lf in summer is higher than in winter

Development checklist: https://nismod.github.io/docs/development-checklist.html https://nismod.github.io/docs/ https://nismod.github.io/docs/smif-prerequisites.html#sector-modeller

energy_demand.main.energy_demand_model(data, fuel_in=0, fuel_in_elec=0)[source]

Main function of energy demand model to calculate yearly demand

Parameters:data (dict) – Data container
Returns:
  • result_dict (dict) – A nested dictionary containing all data for energy supply model with timesteps for every hour in a year. [fuel_type : region : timestep]
  • model_run_object (dict) – Object of a yearly model run

Note

This function is executed in the wrapper

energy_demand.read_and_plot_results module

Module contents

Energy Demand