Skip to content

Commit 1e70fe0

Browse files
Merge pull request #125 from RWTH-EBC/development
Merge development into master
2 parents 3975283 + 88bdf32 commit 1e70fe0

File tree

19 files changed

+4461
-647
lines changed

19 files changed

+4461
-647
lines changed

pycity_calc/economic/annuity_calculation.py

Lines changed: 722 additions & 30 deletions
Large diffs are not rendered by default.

pycity_calc/simulation/energy_balance_optimization/Energy_balance_lhn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def city_energy_balance(City_Object, dict_Qlhn, sortingmethod='CO2', LHN_supply_
6868
for u, v in City_Object.edges():
6969
if u in lhn_con_nodes and v in lhn_con_nodes:
7070
if 'network_type' in City_Object.edge[u][v]:
71-
if City_Object.edge[u][v]['network_type'] == 'heating':
71+
if City_Object.edge[u][v]['network_type'] == 'heating' or City_Object.edge[u][v]['network_type'] == 'heating_and_deg':
7272
# Add street edge to street_graph
7373
lhn_graph.add_edge(u, v, network_type='heating')
7474
temp_vl = City_Object.edge[u][v]['temp_vl']

pycity_calc/simulation/energy_balance_optimization/energy_balance_building.py

Lines changed: 183 additions & 107 deletions
Large diffs are not rendered by default.

pycity_calc/test/test_data_enrich.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ def test_estimate_occ_per_ap(self):
4141
assert (len(list_2) / nb_loops - prob_dist[1]) < 0.01 * prob_dist[1]
4242
assert (len(list_3) / nb_loops - prob_dist[2]) < 0.01 * prob_dist[2]
4343
assert (len(list_4) / nb_loops - prob_dist[3]) < 0.01 * prob_dist[3]
44-
assert (len(list_5) / nb_loops - prob_dist[4]) < 0.01 * prob_dist[4]
44+
# assert (len(list_5) / nb_loops - prob_dist[4]) < 0.01 * prob_dist[4]

pycity_calc/toolbox/mc_helpers/Morris_analysis/Building_evaluation_Morris.py

Lines changed: 235 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,42 @@
88

99
import copy
1010
import numpy as np
11-
import pycity.classes.demand.DomesticHotWater as DomHotWat
12-
11+
import pycity.classes.Weather as Weather
12+
import pycity_calc.environments.environment as env
13+
import pycity_calc.environments.co2emissions as co2
14+
import pycity_calc.environments.market as mark
15+
import pycity_calc.environments.timer as time
16+
import pycity_calc.buildings.building as build_ex
17+
import pycity.classes.demand.Apartment as Apartment
18+
import pycity.classes.demand.ElectricalDemand as ElectricalDemand
19+
import pycity.classes.demand.DomesticHotWater as dhwater
20+
import pycity.classes.demand.Occupancy as occ
1321

1422

1523
def new_evaluation_building(building, parameters):
1624
"""
17-
Rescale Building of a city
25+
Rescale Buildings of a city with new parameters
1826
1927
Parameters
2028
----------
2129
Building : object
2230
Building object of pycity_calc
23-
parameters: np array
31+
Parameters: list
2432
new parameters for buildings
25-
26-
Return : Building
33+
Structure: 0: net_floor_area - percent of modification
34+
1: average_height_of_floors - meters
35+
2: year_of_modernization - new year of modernisation
36+
3: dormer - float [0-2]
37+
4: attic - float [0-4]
38+
5: cellar - float [0-4]
39+
6: construction type - float [-1-1]
40+
7: total_number_occupants - float [0-5]
41+
8: Annual_el_e_dem - percent of modification
42+
9: dhw_Tflow - float - new flow temperature
43+
10: dhw_Tsupply - float - new supply temperature
44+
45+
Return : Building: object
46+
Building Extended object from pycity_calc
2747
-------
2848
2949
"""
@@ -46,31 +66,73 @@ def new_evaluation_building(building, parameters):
4666
# Average height of floors
4767
building.height_of_floors = parameters[1]
4868

49-
# Modification pv roof area
50-
51-
if ref_building.roof_usabl_pv_area is not None:
52-
building.roof_usabl_pv_area = building.roof_usabl_pv_area*(1-parameters[2])
53-
5469
# year of construction and year of modernisation
5570

5671
if ref_building.mod_year is None:
57-
building.build_year = parameters[3]
72+
building.build_year = parameters[2]
5873

5974
else:
60-
building.mod_year = parameters[3]
75+
building.mod_year = parameters[2]
6176

6277
if building.mod_year < building.build_year:
6378

6479
building.build_year = building.mod_year
6580
print('new modification year {}'.format(building.build_year))
6681

82+
# Dormer
83+
if parameters[3]>1:
84+
building.dormer = 1
85+
print ('building has a dormer')
86+
else:
87+
building.dormer = 0
88+
print ('building has no dormer')
89+
90+
# Attic
91+
if parameters[4]<1:
92+
building.attic = 0
93+
print ('building has flat roof')
94+
elif parameters[4]<2:
95+
building.attic = 1
96+
print ('building has non heated attic')
97+
elif parameters[4]<3:
98+
building.attic = 2
99+
print ('buildings has partly heated attic')
100+
else:
101+
building.attic = 3
102+
print ('building has heated attic')
103+
104+
# Cellar
105+
if parameters[5]<1:
106+
building.cellar = 0
107+
print ('building has no cellar')
108+
elif parameters[5]<2:
109+
building.cellar = 1
110+
print('building has non heated cellar')
111+
elif parameters[5]<3:
112+
building.cellar = 2
113+
print('building has partly heated cellar')
114+
else:
115+
building.cellar = 3
116+
print('building has heated cellar')
117+
118+
# Construction type
119+
if parameters[6]>0:
120+
building.construction_type = 'heavy'
121+
print ('construction type: heavy')
122+
else:
123+
building.construction_type = 'light'
124+
print ('construction type: light')
125+
126+
127+
128+
67129
# ##################################################################
68130
# ## Loop over apartment
69131
# ##################################################################
70132

71133
for appart in range(len(building.apartments)):
72134

73-
print('apartment n°: ', appart)
135+
print('\napartment n°: ', appart, '\n')
74136
# ## reference values
75137
ref_appart_occupants = ref_building.apartments[appart].occupancy.number_occupants
76138
ref_annual_el_demand = np.zeros(timestep)
@@ -81,28 +143,173 @@ def new_evaluation_building(building, parameters):
81143

82144
# ## Rescale electrical curve (to do: analysis of appliances, light, season_mod)
83145

84-
curr_occupants = int(parameters[4])
146+
curr_occupants = int(parameters[7])
85147
print('curr nb occupants', curr_occupants)
86148
print('ref nb occupants', ref_appart_occupants)
87-
print()
149+
#print()
88150

89151
temp = ref_el_demand_curve * curr_occupants / ref_appart_occupants
90152
print('ref annual el dem', ref_annual_el_demand)
91-
print('annual el dem', ref_annual_el_demand*(1-parameters[5]))
153+
print('annual el dem', ref_annual_el_demand*(1-parameters[8]))
92154

93-
# parameter 5: user annual electrical consumption
94-
building.apartments[appart].power_el.loadcurve = temp * (1-parameters[5])
95-
print('building el curve', building.apartments[appart].power_el.loadcurve)
96-
print('ref el curve', ref_el_demand_curve)
155+
# parameter 8: user annual electrical consumption
156+
building.apartments[appart].power_el.loadcurve = temp * (1-parameters[8])
157+
#print('building el curve', building.apartments[appart].power_el.loadcurve)
158+
#print('ref el curve', ref_el_demand_curve)
97159

98160
# ## Rescaling domestic hot water
99-
tFlow = parameters[6]
100-
Tsupply = parameters[7]
101161

102-
building.apartments[appart].demandDomesticHotWater = \
103-
DomHotWat.DomesticHotWater(building.environment, tFlow=tFlow, method=2, supplyTemperature=Tsupply,
104-
occupancy=building.apartments[appart].occupancy.occupancy)
162+
tFlow = parameters[9]
163+
Tsupply = parameters[10]
164+
t_diff_ref = ref_building.apartments[appart].demandDomesticHotWater.tFlow - 25
165+
166+
# stochastic generation of domestic hot water: rescale with new water temperature difference
167+
# otherwise impact on the sensitivity analysis
168+
ref_dhw = ref_building.apartments[appart].demandDomesticHotWater.get_power(currentValues=False,
169+
returnTemperature=False)
170+
171+
building.apartments[appart].demandDomesticHotWater.loadcurve = ref_dhw*(tFlow-Tsupply)/t_diff_ref
172+
#print ('\nNew dhw curve generation')
173+
#print('DHW', building.apartments[appart].demandDomesticHotWater)
174+
175+
return building
176+
177+
178+
if __name__ == '__main__':
105179

106-
print('DHW', building.apartments[appart].demandDomesticHotWater)
180+
# ## Building generation
181+
# ######################
107182

108-
return building
183+
# Define simulation settings
184+
build_year = 1962 # Year of construction
185+
mod_year = None # Year of retrofit
186+
net_floor_area = 200 # m2
187+
height_of_floors = 2.8 # m
188+
nb_of_floors = 2 # m
189+
num_occ = 3 # Set fix to prevent long run time for multiple new occupancy
190+
# and electrical load profiles
191+
192+
# # Create PyCity_Calc environment
193+
# ###############################################################
194+
195+
# Create extended environment of pycity_calc
196+
year = 2010
197+
timestep = 3600 # Timestep in seconds
198+
location = (51.529086, 6.944689) # (latitude, longitute) of Bottrop
199+
altitude = 55 # Altitude of Bottrop
200+
201+
# ###############################################################
202+
203+
# Generate timer object
204+
timer = time.TimerExtended(timestep=timestep, year=year)
205+
206+
# Generate weather object
207+
weather = Weather.Weather(timer, useTRY=True, location=location,
208+
altitude=altitude)
209+
210+
# Generate market object
211+
market = mark.Market()
212+
213+
# Generate co2 emissions object
214+
co2em = co2.Emissions(year=year)
215+
216+
# Generate environment
217+
environment = env.EnvironmentExtended(timer, weather, prices=market,
218+
location=location, co2em=co2em)
219+
220+
# # Create occupancy profile
221+
# #####################################################################
222+
223+
print('Calculate occupancy.\n')
224+
# Generate occupancy profile
225+
occupancy_obj = occ.Occupancy(environment, number_occupants=num_occ)
226+
227+
print('Finished occupancy calculation.\n')
228+
229+
# # Create electrical load
230+
# #####################################################################
231+
232+
print('Calculate el. load.\n')
233+
234+
el_dem_stochastic = ElectricalDemand.ElectricalDemand(environment,
235+
method=2,
236+
annualDemand=3000, # Dummy value
237+
do_normalization=True,
238+
total_nb_occupants=num_occ,
239+
randomizeAppliances=True,
240+
lightConfiguration=10,
241+
occupancy=occupancy_obj.occupancy[:])
242+
243+
print('Finished el. load calculation.\n')
244+
245+
# # Create dhw load
246+
# #####################################################################
247+
dhw_stochastical = dhwater.DomesticHotWater(environment,
248+
tFlow=60,
249+
thermal=True,
250+
method=2,
251+
supplyTemperature=20,
252+
occupancy=occupancy_obj.occupancy)
253+
254+
# # Create apartment and building object
255+
# #####################################################################
256+
257+
# Create apartment
258+
apartment = Apartment.Apartment(environment)
259+
260+
# Add demands to apartment
261+
apartment.addMultipleEntities([el_dem_stochastic, occupancy_obj,
262+
dhw_stochastical])
263+
264+
# Create extended building object
265+
extended_building = build_ex.BuildingExtended(environment,
266+
build_year=build_year,
267+
mod_year=mod_year,
268+
build_type=0,
269+
roof_usabl_pv_area=30,
270+
net_floor_area=net_floor_area,
271+
height_of_floors=height_of_floors,
272+
nb_of_floors=nb_of_floors,
273+
neighbour_buildings=0,
274+
residential_layout=0,
275+
attic=1, cellar=1,
276+
construction_type='heavy',
277+
dormer=1)
278+
279+
# Add apartment to extended building
280+
extended_building.addEntity(entity=apartment)
281+
282+
# ## New parameters
283+
# #################
284+
list_pam = []
285+
286+
net_floor_area = 0.10
287+
list_pam.append(net_floor_area)
288+
average_height_of_floors = 2.7
289+
list_pam.append(average_height_of_floors)
290+
year_of_modernization = 1993
291+
list_pam.append(year_of_modernization)
292+
dormer = 0
293+
list_pam.append(dormer)
294+
attic = 4
295+
list_pam.append(attic)
296+
cellar = 4
297+
list_pam.append(cellar)
298+
construction_type = 0.4
299+
list_pam.append(construction_type)
300+
total_number_occupants = 4
301+
list_pam.append(total_number_occupants)
302+
Annual_el_e_dem = 0.3
303+
list_pam.append(Annual_el_e_dem)
304+
dhw_Tflow = 60
305+
list_pam.append(dhw_Tflow)
306+
dhw_Tsupply = 25
307+
list_pam.append(dhw_Tsupply)
308+
309+
print ('new parameters : ', list_pam)
310+
311+
312+
313+
extended_building = new_evaluation_building(extended_building, list_pam)
314+
315+
print ('End')
Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,60 @@
1-
longitude 50 50.001latitude 6.00 6.001Altitude 263 268weather -1 1net_floor_area -0.025 0.025average_height_of_floors 2.6 2.7Usable_pv_roof_area -0.05 0.05year_of_modernization 1970 2015total_number_occupants 1 5Annual_el_e_dem -0.05 0.05dhw_Tflow 55 65dhw_Tsupply 20 30vent_factor 0.1 1tset_heat 18 25tset_night 13 20eta_battery_charge 0.9 0.97eta_battery_discharge 0.9 0.97self_discharge_battery 0.005 0.015T_max_TES 75 85T_min_TES 18 22T_surrounding 18 22klosses_TES 0.25 0.35T_init_TES 18 22eta_boiler 0.8 0.95LAL_boiler 0.15 0.25T_max_boiler 85 95eta_CHP 0.8 0.95T_max_CHP 85 95LAL_CHP 0.55 0.65eta_EH 0.9 1T_max_EH 80 90LAL_HP 0.45 0.55T_max_HP 50 60T_sink_HP 35 55eta_PV 0.11 0.19Tnom_PV 40 50alpha_PV -0.01 0.01beta_PV 0 180gamma_PV -180 180tau_alpha_PV 0.8 0.99price_ch_cap 1.005 1.05price_ch_dem_gas 1.005 1.05price_ch_dem_el 1.005 1.05price_ch_op 1.010 1.04price_ch_proc_chp 1.005 1.02price_ch_proc_pv 0.95 0.99price_ch_EEG_Umlage_tax_chp 1 1.01price_ch_EEG_Umlage_tax_pv 1 1.01price_EEX_baseload_price 0.97 1.04price_ch_avoid_grid_usage 1 1.02price_ch_sub_chp 0.99 1.01price_ch_self_usage_chp 0.995 1.005price_ch_gas_disc_chp 0.995 1.005price_ch_sub_pv 0.95 0.98life_factor 0.9 1.1maintenance_factor 0.9 1.1
1+
longitude 50.775 50.777
2+
latitude 6.083 6.085
3+
Altitude 260 270
4+
weather -1 1
5+
net_floor_area -0.1 0.1
6+
average_height_of_floors 2.4 3
7+
year_of_modernization 1977 2015
8+
dormer 0 2
9+
attic 0 4
10+
cellar 0 4
11+
construction type -1 1
12+
total_number_occupants 1 5
13+
Annual_el_e_dem -0.5 0.5
14+
dhw_Tflow 45 75
15+
dhw_Tsupply 10 35
16+
vent_factor 0.1 1
17+
tset_heat 19 25
18+
tset_night 15 19
19+
eta_battery_charge 0.8 0.97
20+
eta_battery_discharge 0.9 0.97
21+
self_discharge_battery 0.005 0.015
22+
T_max_TES 75 85
23+
T_min_TES 18 19
24+
T_surrounding 18 19
25+
klosses_TES 0.25 0.35
26+
T_init_TES 19 20
27+
eta_boiler 0.4 0.95
28+
LAL_boiler 0.05 0.4
29+
T_max_boiler 60 100
30+
eta_CHP 0.8 0.95
31+
T_max_CHP 85 95
32+
LAL_CHP 0.55 0.65
33+
eta_EH 0.9 1
34+
T_max_EH 80 90
35+
LAL_HP 0.45 0.55
36+
T_max_HP 50 60
37+
T_sink_HP 35 55
38+
eta_PV 0.11 0.19
39+
Tnom_PV 40 50
40+
alpha_PV -0.01 0.01
41+
beta_PV 0 180
42+
gamma_PV -180 180
43+
tau_alpha_PV 0.8 0.99
44+
price_ch_cap 1.005 1.15
45+
price_ch_dem_gas 1.005 1.15
46+
price_ch_dem_el 1.005 1.15
47+
price_ch_op 1.010 1.15
48+
price_ch_proc_chp 1.005 1.02
49+
price_ch_proc_pv 0.95 0.99
50+
price_ch_EEG_Umlage_tax_chp 1 1.01
51+
price_ch_EEG_Umlage_tax_pv 1 1.01
52+
price_EEX_baseload_price 0.97 1.04
53+
price_ch_avoid_grid_usage 1 1.02
54+
price_ch_sub_chp 0.99 1.01
55+
price_ch_self_usage_chp 0.995 1.005
56+
price_ch_gas_disc_chp 0.995 1.005
57+
price_ch_sub_pv 0.95 0.98
58+
life_factor 0.6 1.4
59+
maintenance_factor 0.5 1.5
60+
interest 0.001 0.2

0 commit comments

Comments
 (0)