8
8
9
9
import copy
10
10
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
13
21
14
22
15
23
def new_evaluation_building (building , parameters ):
16
24
"""
17
- Rescale Building of a city
25
+ Rescale Buildings of a city with new parameters
18
26
19
27
Parameters
20
28
----------
21
29
Building : object
22
30
Building object of pycity_calc
23
- parameters: np array
31
+ Parameters: list
24
32
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
27
47
-------
28
48
29
49
"""
@@ -46,31 +66,73 @@ def new_evaluation_building(building, parameters):
46
66
# Average height of floors
47
67
building .height_of_floors = parameters [1 ]
48
68
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
-
54
69
# year of construction and year of modernisation
55
70
56
71
if ref_building .mod_year is None :
57
- building .build_year = parameters [3 ]
72
+ building .build_year = parameters [2 ]
58
73
59
74
else :
60
- building .mod_year = parameters [3 ]
75
+ building .mod_year = parameters [2 ]
61
76
62
77
if building .mod_year < building .build_year :
63
78
64
79
building .build_year = building .mod_year
65
80
print ('new modification year {}' .format (building .build_year ))
66
81
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
+
67
129
# ##################################################################
68
130
# ## Loop over apartment
69
131
# ##################################################################
70
132
71
133
for appart in range (len (building .apartments )):
72
134
73
- print ('apartment n°: ' , appart )
135
+ print ('\n apartment n°: ' , appart , ' \n ' )
74
136
# ## reference values
75
137
ref_appart_occupants = ref_building .apartments [appart ].occupancy .number_occupants
76
138
ref_annual_el_demand = np .zeros (timestep )
@@ -81,28 +143,173 @@ def new_evaluation_building(building, parameters):
81
143
82
144
# ## Rescale electrical curve (to do: analysis of appliances, light, season_mod)
83
145
84
- curr_occupants = int (parameters [4 ])
146
+ curr_occupants = int (parameters [7 ])
85
147
print ('curr nb occupants' , curr_occupants )
86
148
print ('ref nb occupants' , ref_appart_occupants )
87
- print ()
149
+ # print()
88
150
89
151
temp = ref_el_demand_curve * curr_occupants / ref_appart_occupants
90
152
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 ]))
92
154
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)
97
159
98
160
# ## Rescaling domestic hot water
99
- tFlow = parameters [6 ]
100
- Tsupply = parameters [7 ]
101
161
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__' :
105
179
106
- print ('DHW' , building .apartments [appart ].demandDomesticHotWater )
180
+ # ## Building generation
181
+ # ######################
107
182
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' )
0 commit comments