-
Notifications
You must be signed in to change notification settings - Fork 26
/
neighbourhood.py
executable file
·130 lines (110 loc) · 5.52 KB
/
neighbourhood.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#Copyright (C) 2023 University of Twente
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program. If not, see <http://www.gnu.org/licenses/>.
from configLoader import *
config = importlib.import_module(cfgFile)
import houses
class neighbourhood:
print("Creating Neighbourhood")
houseList = []
pvList = [0] * len(config.householdList)
batteryList = [0] * len(config.householdList)
inductioncookingList = [0] * len(config.householdList)
for i in range(0, len(config.householdList)):
houseList.append(houses.House())
#Add PV to houses:
for i in range(0, len(config.householdList)):
if i < (round(len(config.householdList)*(config.penetrationPV/100))):
pvList[i] = 1
#And randomize:
random.shuffle(pvList)
#Add induction cooking
for i in range(0, len(config.householdList)):
if i < (round(len(config.householdList)*(config.penetrationInductioncooking/100))):
inductioncookingList[i] = 1
random.shuffle(inductioncookingList)
for i in range(0, len(config.householdList)):
if inductioncookingList[i] == 1:
config.householdList[i].hasInductionCooking = True
# Add Combined Heat Power
i = 0
while i < (round(len(config.householdList)*(config.penetrationCHP/100))) - (round(len(config.householdList)*(config.penetrationPV/100))):
j = random.randint(0,len(config.householdList)-1)
if config.householdList[j].hasCHP == False and pvList[j] == 0: # First supply houses without PV
config.householdList[j].hasCHP = True
i = i + 1
if (round(len(config.householdList)*(config.penetrationPV/100))) > (round(len(config.householdList)*(config.penetrationCHP/100))): # If there are too much CHPs compared to PV, add some more CHPS
while i < (round(len(config.householdList)*(config.penetrationCHP/100))):
j = random.randint(0,len(config.householdList)-1)
if config.householdList[j].hasCHP == False: # First supply houses without PV
config.householdList[j].hasCHP = True
i = i + 1
# Add heat pumps
i = 0
while i < (round(len(config.householdList)*(config.penetrationHeatPump/100))):
j = random.randint(0,len(config.householdList)-1)
if config.householdList[j].hasHP == False and config.householdList[j].hasCHP == False:
config.householdList[j].hasHP = True
i = i + 1
#Now add batteries
i = 0
while i < (round(len(config.householdList)*(config.penetrationBattery/100))):
j = random.randint(0,len(config.householdList)-1)
if (pvList[j] == 1 or config.householdList[j].hasCHP) and batteryList[j] == 0:
batteryList[j] = 1
i = i + 1
# Add EVs
drivingDistance = [0] * len(config.householdList)
for i in range(0, len(config.householdList)):
drivingDistance[i] = config.householdList[i].Persons[0].DistanceToWork
drivingDistance = sorted(drivingDistance, reverse=True)
for i in range(0, len(drivingDistance)):
if i < (round(len(config.householdList)*(config.penetrationEV/100))+round(len(config.householdList)*(config.penetrationPHEV/100))):
#We can still add an EV
added = False
j = 0
while added == False:
if config.householdList[j].Persons[0].DistanceToWork == drivingDistance[i]:
if config.householdList[j].hasEV == False:
if i < (round(len(config.householdList)*(config.penetrationEV/100))):
config.householdList[j].Devices["ElectricalVehicle"].BufferCapacity = config.capacityEV
config.householdList[j].Devices["ElectricalVehicle"].Consumption = config.powerEV
else:
config.householdList[j].Devices["ElectricalVehicle"].BufferCapacity = config.capacityPHEV
config.householdList[j].Devices["ElectricalVehicle"].Consumption = config.powerPHEV
config.householdList[j].hasEV = True
added = True
j = j + 1
#Shuffle
random.shuffle(config.householdList)
#And then map households to houses
for i in range(0,len(config.householdList)):
config.householdList[i].setHouse(houseList[i])
#add solar panels according to the size of the annual consumption:
if pvList[i] == 1:
# Do something fancy
# A solar panel will produce approx 875kWh per kWp on annual basis in the Netherlands:
# https://www.consumentenbond.nl/energie/extra/wat-zijn-zonnepanelen/
# Furthermore, the size of a single solar panel is somewhere around 1.6m2 (various sources)
# Hence, if a household is to be more or less energy neutral we have:
area = round( (config.householdList[i].ConsumptionYearly / config.PVProductionPerYear) * 1.6) #average panel is 1.6m2
config.householdList[i].House.addPV(area)
if batteryList[i] == 1:
# Do something based on the household size and whether the house has an EV:
if config.householdList[i].hasEV:
#House has an EV as well!
config.householdList[i].House.addBattery(config.capacityBatteryLarge, config.powerBatteryLarge) #Let's give it a nice battery!
else:
#NO EV, just some peak shaving:
if(config.householdList[i].ConsumptionYearly > 2500):
config.householdList[i].House.addBattery(config.capacityBatteryMedium, config.powerBatteryMedium)
else:
config.householdList[i].House.addBattery(config.capacityBatterySmall, config.powerBatterySmall)