initialer commit
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
__pycache__/
|
||||||
17
main.py
Normal file
17
main.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
from neighborhood import Producer, Consumer, Neighborhood
|
||||||
|
|
||||||
|
# Anzahl Haushalte ohne PV-Anlagen
|
||||||
|
num_consumer = 50
|
||||||
|
avg_consumption_per_consumer = 10
|
||||||
|
|
||||||
|
# Anzahl Haushalte mit PV-Anlagen
|
||||||
|
num_producer = 10
|
||||||
|
avg_production_per_producer = 20
|
||||||
|
|
||||||
|
# Instanzen für Erzeuger und Verbraucher anlegen
|
||||||
|
consumer = Consumer(num_consumer, avg_consumption_per_consumer)
|
||||||
|
producer = Producer(num_producer, avg_consumption_per_consumer, avg_production_per_producer)
|
||||||
|
|
||||||
|
# Instanz für Nachbarschaft anlegen und Ergebnis plotten
|
||||||
|
neighborhood = Neighborhood(producer, consumer)
|
||||||
|
neighborhood.plot_consumption()
|
||||||
93
neighborhood.py
Normal file
93
neighborhood.py
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
import numpy as np
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
class Consumer:
|
||||||
|
def __init__(self, quantity, average_consumption):
|
||||||
|
self.quantity = quantity
|
||||||
|
self.consumption_profile = self.create_consumption_profile()
|
||||||
|
self.average_consumption = average_consumption
|
||||||
|
|
||||||
|
def create_consumption_profile(self):
|
||||||
|
profile = np.zeros(24)
|
||||||
|
peak_hours = [12]
|
||||||
|
for hour in peak_hours:
|
||||||
|
profile[hour] = 1.5
|
||||||
|
for hour in range(24):
|
||||||
|
if hour not in peak_hours:
|
||||||
|
profile[hour] = 0.8
|
||||||
|
return profile
|
||||||
|
|
||||||
|
def calculate_daily_consumption(self):
|
||||||
|
daily_consumption = self.quantity * self.average_consumption * self.consumption_profile
|
||||||
|
return daily_consumption
|
||||||
|
|
||||||
|
class Producer:
|
||||||
|
def __init__(self, quantity, average_consumption, average_production):
|
||||||
|
self.quantity = quantity
|
||||||
|
self.consumption_profile = self.create_consumption_profile()
|
||||||
|
self.average_consumption = average_consumption
|
||||||
|
self.production_profile = self.create_production_profile()
|
||||||
|
self.average_production = average_production
|
||||||
|
|
||||||
|
def create_consumption_profile(self):
|
||||||
|
profile = np.zeros(24)
|
||||||
|
peak_hours = [8,12,13,18,19,20,21]
|
||||||
|
for hour in peak_hours:
|
||||||
|
profile[hour] = 1.5
|
||||||
|
for hour in range(24):
|
||||||
|
if hour not in peak_hours:
|
||||||
|
profile[hour] = 0.5
|
||||||
|
return profile
|
||||||
|
|
||||||
|
def create_production_profile(self):
|
||||||
|
profile = np.zeros(24)
|
||||||
|
peak_hours = [8,9,10,11,12,13,14,15,16,17,18,19]
|
||||||
|
for hour in peak_hours:
|
||||||
|
profile[hour] = 1.5
|
||||||
|
for hour in range(24):
|
||||||
|
if hour not in peak_hours:
|
||||||
|
profile[hour] = 0
|
||||||
|
return profile
|
||||||
|
|
||||||
|
def calculate_daily_consumption(self):
|
||||||
|
daily_consumption = self.quantity * self.average_consumption * self.consumption_profile
|
||||||
|
return daily_consumption
|
||||||
|
|
||||||
|
def calculate_daily_production(self):
|
||||||
|
daily_production = self.quantity * self.average_production * self.production_profile
|
||||||
|
return daily_production
|
||||||
|
|
||||||
|
class Neighborhood:
|
||||||
|
def __init__(self, producer, consumer):
|
||||||
|
self.producer = producer
|
||||||
|
self.consumer = consumer
|
||||||
|
|
||||||
|
def plot_consumption(self):
|
||||||
|
total_consumption = -1*(self.consumer.calculate_daily_consumption() + self.producer.calculate_daily_consumption())
|
||||||
|
total_production = self.producer.calculate_daily_production()
|
||||||
|
net_value = total_consumption + total_production
|
||||||
|
|
||||||
|
# X-Werte anlegen
|
||||||
|
x = range(24)
|
||||||
|
x_labels = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24']
|
||||||
|
# Plot dimensionieren
|
||||||
|
plt.figure(figsize=(10, 6))
|
||||||
|
# y-Werte den x-Werten zuordnen
|
||||||
|
plt.plot(x, total_consumption, '--', x, total_production, '--', x, net_value, '-')
|
||||||
|
# Titel und Achsenbeschriftungen anlegen
|
||||||
|
plt.xlabel('Stunde')
|
||||||
|
plt.ylabel('Strom (kWh)')
|
||||||
|
plt.title('Produktion/Verbrauch Nachbarschaft')
|
||||||
|
# X-Werten die Labels zuordnen
|
||||||
|
plt.xticks(x, x_labels)
|
||||||
|
# Legende anlegen
|
||||||
|
plt.legend(['Verbrauch', 'Produktion', 'Netto-Wert'], loc='upper right')
|
||||||
|
# X-Labels rotieren
|
||||||
|
plt.xticks(rotation=45)
|
||||||
|
# Grid anlegen
|
||||||
|
plt.grid(color='black', axis='y', linestyle='--', linewidth=0.5)
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user