simple-pv-simulator/config.py

48 lines
1.8 KiB
Python
Raw Permalink Normal View History

2024-05-03 13:44:12 +02:00
import pandas as pd
2024-05-03 12:20:19 +02:00
class pv_config:
2024-05-03 15:36:02 +02:00
def __init__(self, capacity, cost_per_kW, lifetime, loss):
2024-05-03 12:20:19 +02:00
self.capacity = capacity
self.cost_per_kW = cost_per_kW
2024-05-03 15:36:02 +02:00
self.lifetime = lifetime
self.loss = loss
2024-05-06 19:24:11 +02:00
def get_cost(self):
return self.capacity * self.cost_per_kW
def get_cost_per_year(self):
return self.capacity * self.cost_per_kW / self.lifetime
2024-05-03 12:20:19 +02:00
class ess_config:
2024-05-15 15:06:43 +02:00
def __init__(self, capacity, cost_per_kW, lifetime, loss, charge_power, discharge_power, storage=0):
2024-05-03 12:20:19 +02:00
self.capacity = capacity
self.cost_per_kW = cost_per_kW
2024-05-03 15:36:02 +02:00
self.lifetime = lifetime
self.loss = loss
2024-05-15 15:06:43 +02:00
self.storage = storage
2024-05-03 13:44:12 +02:00
self.charge_power = charge_power
self.discharge_power = discharge_power
2024-05-06 19:24:11 +02:00
def get_cost(self):
return self.capacity * self.cost_per_kW
def get_cost_per_year(self):
return self.capacity * self.cost_per_kW / self.lifetime
2024-05-03 13:44:12 +02:00
class grid_config:
2024-05-04 09:58:05 +02:00
def __init__(self, capacity, grid_loss, sell_price):
# self.price_schedule = price_schedule
2024-05-03 15:12:52 +02:00
self.loss = grid_loss
2024-05-03 14:08:18 +02:00
self.sell_price = sell_price
self.capacity = capacity
2024-05-03 13:44:12 +02:00
def get_price_for_time(self, time):
hour, minute = map(int, time.split(':'))
total_minutes = hour * 60 + minute
for _, row in self.price_schedule.iterrows():
start_hour, start_minute = map(int, row['time_start'].split(':'))
end_hour, end_minute = map(int, row['time_end'].split(':'))
start_total_minutes = start_hour * 60 + start_minute
end_total_minutes = end_hour * 60 + end_minute
if start_total_minutes <= total_minutes < end_total_minutes:
return row['price']
return 0.1 # 默认电价,以防万一没有匹配的时间段
2024-05-03 12:20:19 +02:00