Skip to content

Commit

Permalink
working on building stock generator
Browse files Browse the repository at this point in the history
  • Loading branch information
eggimasv authored and eggimasv committed Feb 28, 2017
1 parent 11fa887 commit ae4db71
Show file tree
Hide file tree
Showing 9 changed files with 52,794 additions and 52,649 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
2009,21.46556448,36.68186156,29.6079356,8.031695795,4.21294257
2010,21.73061688,36.39767665,28.95289978,7.908182763,5.010623934
2011,20.82643491,36.31645864,29.44333304,8.00677683,5.407611848
2015,20.82643491,36.31645864,29.44333304,8.00677683,5.407611848
2015,20.8,36.3,29.5,8.0,5.4
7 changes: 3 additions & 4 deletions energy_demand/assumptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ def load_assumptions():
# ------------------------------------------------------------------------

# Building stock related
change_floor_area_pp = -0.1 # Assumption of change in floor area up to end_year ASSUMPTION


#assump_dwtype_distr = {'semi_detached': 26.0, 'terraced': 28.3, 'flat': 20.3, 'detached': 16.6, 'bungalow': 8.8} # Assumption of distribution of dwelling types in end_year ASSUMPTION
change_floor_area_pp = -0.1 # Assumption of change in floor area up to end_year ASSUMPTION
assump_dwtype_distr = {'semi_detached': 20.0, 'terraced': 20, 'flat': 30, 'detached': 20, 'bungalow': 10} # Assumption of distribution of dwelling types in end_year ASSUMPTION



Expand All @@ -34,5 +32,6 @@ def load_assumptions():

# Add to dictionary
assumptions_dict['change_floor_area_pp'] = change_floor_area_pp
assumptions_dict['assump_dwtype_distr'] = assump_dwtype_distr

return assumptions_dict
125 changes: 96 additions & 29 deletions energy_demand/building_stock_functions.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
""" Functions for building stock"""

# pylint: disable=I0011,C0321,C0301,C0103, C0325


class Dwelling(object):
"""Class of a single dwelling or of a aggregated group of dwelling"""

Expand All @@ -25,7 +23,6 @@ def __init__(self, coordinates, dwtype, house_id, age, pop, floor_area, temp):
Floor area of dwelling
temp : float
Climate variable...(tbd)
"""
self.house_id = house_id
self.coordinates = coordinates
Expand Down Expand Up @@ -83,48 +80,48 @@ class BuildingStockRegion(object):
"""Class of the building stock in a region"""
# TODO: Include old and new stock

def __init__(self, region_ID, dwelling_list):
def __init__(self, region_ID, dwellings):
"""Returns a new building stock region object.
Parameters
----------
region_ID : float
Region ID of building stock
dwelling_list : list
dwellings : list
List containing all dwelling objects
"""
self.region_ID = region_ID
self.dwelling_list = dwelling_list
self.dwellings = dwellings

def get_tot_pop(self):
""" Get total population"""
totpop = 0
for dwelling in self.dwelling_list:
totpop += dwelling.pop()
return totpop
for dwelling in self.dwellings:
#print(dwelling.__dict__)
totpop += dwelling.pop
return round(totpop, 3)

def get_sum_scenario_driver_water_heating(self):
""" Sum all scenario driver for water heating"""
sum_driver = 0
for dwelling in self.dwelling_list:
sum_driver += dwelling.scenario_driver_water_heating()
for dwelling in self.dwellings:
sum_driver += dwelling.scenario_driver_water_heating
return sum_driver

def get_sum_scenario_driver_space_heating(self):
""" Sum all scenario driver for space heating"""
sum_driver = 0
for dwelling in self.dwelling_list:
sum_driver += dwelling.scenario_driver_space_heating()
for dwelling in self.dwellings:
sum_driver += dwelling.scenario_driver_space_heating
return sum_driver

def get_sum_scenario_driver_lighting(self):
""" Sum all scenario driver for lighting heating"""
sum_driver = 0
for dwelling in self.dwelling_list:
sum_driver += dwelling.scenario_driver_lighting()
for dwelling in self.dwellings:
sum_driver += dwelling.scenario_driver_lighting
return sum_driver


def get_floor_area_pp(reg_floor_area, reg_pop, global_variables, assump_final_diff_floor_area_pp):
""" Calculates future floor area per person depending on
assumptions on final change and base year data
Expand All @@ -139,7 +136,7 @@ def get_floor_area_pp(reg_floor_area, reg_pop, global_variables, assump_final_di
global_variables : dict
Contains all global simulation variables
assump_final_diff_floor_area_pp : float
Assumption of change in floor area up to end of simulation
Expand All @@ -162,25 +159,95 @@ def get_floor_area_pp(reg_floor_area, reg_pop, global_variables, assump_final_di
sim_years = {}
floor_area_pp_by = reg_floor_area[reg_id] / reg_pop[reg_id] # Floor area per person of base year

# Iterate simulation years
for y in sim_period:
sim_year = y - global_variables['base_year']
curr_year = y - global_variables['base_year']

if y == base_year:
sim_years[y] = floor_area_pp_by # base year value
else:
# Change up to current year
diff_cy = sim_year * (((1 + assump_final_diff_floor_area_pp) - 1) / (len(sim_period)-1)) # substract from sim_period 1 because of base year
# Change up to current year (linear)
diff_cy = curr_year * (((1 + assump_final_diff_floor_area_pp) - 1) / (len(sim_period)-1)) # substract from sim_period 1 because of base year
floor_ara_pp_sim_year = floor_area_pp_by * (1 + diff_cy) # Floor area of simulation year
sim_years[y] = floor_ara_pp_sim_year
data_floor_area_pp[reg_id] = sim_years # Values for every simulation year

# Floor area of simulation year
floor_ara_pp_sim_year = floor_area_pp_by * (1 + diff_cy)
return data_floor_area_pp

sim_years[y] = floor_ara_pp_sim_year
def get_dwtype_dist(base_dwtype_distr, assump_dwtype_distr, global_variables):
"""Calculates the yearly distribution of dw types
based on assumption of distribution on end_year
# Values for every simulation year
data_floor_area_pp[reg_id] = sim_years
Linear change over time
return data_floor_area_pp
# Todo: Check modelling interval (2050/2051)
Parameters
----------
base_dwtype_distr : dict
Distribution of dwelling types base year
assump_dwtype_distr : dict
Distribution of dwelling types end year
global_variables : dict
Contains all global simulation variables
Returns
-------
dwtype_distr : dict
Contains all dwelling type distribution for every year
"""

dwtype_distr = {}
sim_period = range(global_variables['base_year'], global_variables['end_year'] + 1, 1) #base year, current year, iteration step

# Iterate years
for current_year in sim_period:
sim_year = current_year - global_variables['base_year']
y_distr = {}

# iterate type
for dtype in base_dwtype_distr:
val_by = base_dwtype_distr[dtype] # base year value
val_cy = assump_dwtype_distr[dtype] # cur year value

diff_val = val_cy - val_by # Total difference
diff_y = diff_val / (len(sim_period)-1) # Linear difference per year

y_distr[dtype] = val_by + (diff_y * sim_year) # Differene up to current year
dwtype_distr[current_year] = y_distr

return dwtype_distr

def get_dwtype_age_distr(get_dwtype_age_distr_base):
"""Calculates age distribution
Linear change over time
# Todo: Check modelling interval (2050/2051)
Parameters
----------
base_dwtype_distr : dict
Distribution of dwelling types base year
assump_dwtype_distr : dict
Distribution of dwelling types end year
global_variables : dict
Contains all global simulation variables
Returns
-------
dwtype_distr : dict
Contains all dwelling type distribution for every year
"""
print(get_dwtype_age_distr_base)

# {'1918': 20.82643491, '1941': 36.31645864, '1977.5': 29.44333304, '1996.5': 8.00677683, '2002': 5.407611848}


prnt("...")

def get_dwtype_dist():

return
return dwtype_age_distr_sim

0 comments on commit ae4db71

Please sign in to comment.