update variable name
This commit is contained in:
parent
09ef44fc21
commit
88240280ca
@ -9,9 +9,8 @@ class EnergySystem:
|
||||
# 优先使用PV供电给工厂 - 如果PV输出能满足工厂的需求,则直接供电,多余的电能用来给ESS充电。
|
||||
# PV不足时使用ESS补充 - 如果PV输出不足以满足工厂需求,首先从ESS获取所需电量。
|
||||
# 如果ESS也不足以满足需求,再从电网获取 - 当ESS中的存储电量也不足以补充时,再从电网购买剩余所需电量。
|
||||
def simulate(self, data):
|
||||
def simulate(self, data, time_interval):
|
||||
total_benefit = 0
|
||||
time_interval = 10 / 60 # 时间间隔,单位小时(10分钟)
|
||||
for index, row in data.iterrows():
|
||||
time = row['time']
|
||||
sunlight_intensity = row['sunlight']
|
||||
@ -22,14 +21,18 @@ class EnergySystem:
|
||||
generated_pv_energy = generated_pv_power * time_interval * self.pv.loss # 生成的能量,单位 kWh
|
||||
|
||||
if generated_pv_energy >= factory_demand * time_interval:
|
||||
# 剩余的能量(kwh) = pv生成的能量 - 工厂需求的功率 * 时间间隔
|
||||
surplus_energy = generated_pv_energy - factory_demand * time_interval
|
||||
# 要充到ess中的能量 = min(剩余的能量,ess的充电功率*时间间隔(ess在时间间隔内能充进的电量),ess的容量-ess储存的能量(ess中能冲进去的电量))
|
||||
charge_to_ess = min(surplus_energy, self.ess.charge_power * time_interval, self.ess.capacity - self.ess.storage)
|
||||
self.ess.storage += charge_to_ess
|
||||
surplus_after_ess = surplus_energy - charge_to_ess
|
||||
# 如果还有电量盈余,且pv功率大于ess的充电功率+工厂的需求功率则准备卖电
|
||||
if surplus_after_ess > 0 and generated_pv_power > self.ess.charge_power + factory_demand:
|
||||
sold_to_grid = surplus_after_ess
|
||||
sell_income = sold_to_grid * self.grid.sell_price
|
||||
total_benefit += sell_income
|
||||
# 节省的能量 = 工厂需求的能量 * 时间段
|
||||
total_energy = factory_demand * time_interval
|
||||
else:
|
||||
needed_from_ess = factory_demand * time_interval - generated_pv_energy
|
||||
|
12
config.py
12
config.py
@ -1,16 +1,16 @@
|
||||
import pandas as pd
|
||||
class pv_config:
|
||||
def __init__(self, capacity, cost_per_kW, pv_lifetime, pv_loss):
|
||||
def __init__(self, capacity, cost_per_kW, lifetime, loss):
|
||||
self.capacity = capacity
|
||||
self.cost_per_kW = cost_per_kW
|
||||
self.lifetime = pv_lifetime
|
||||
self.loss = pv_loss
|
||||
self.lifetime = lifetime
|
||||
self.loss = loss
|
||||
class ess_config:
|
||||
def __init__(self, capacity, cost_per_kW, ess_lifetime, ess_loss, charge_power, discharge_power):
|
||||
def __init__(self, capacity, cost_per_kW, lifetime, loss, charge_power, discharge_power):
|
||||
self.capacity = capacity
|
||||
self.cost_per_kW = cost_per_kW
|
||||
self.lifetime = ess_lifetime
|
||||
self.loss = ess_loss
|
||||
self.lifetime = lifetime
|
||||
self.loss = loss
|
||||
self.storage = 0
|
||||
self.charge_power = charge_power
|
||||
self.discharge_power = discharge_power
|
||||
|
20
main.py
20
main.py
@ -1 +1,21 @@
|
||||
import matplotlib
|
||||
import pandas as pd
|
||||
from EnergySystem import EnergySystem
|
||||
from config import pv_config, grid_config, ess_config
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
price_schedule = pd.read_csv('price_schedule.csv')
|
||||
data = pd.read_csv('simulation_data.csv')
|
||||
|
||||
|
||||
pv = pv_config(capacity=100000,cost_per_kW=200,lifetime=25,loss=0.95)
|
||||
ess = ess_config(capacity=100000,cost_per_kW=300,lifetime=25,loss=0.95,charge_power=100000,discharge_power=100000)
|
||||
grid = grid_config(price_schedule=price_schedule, capacity=5000, grid_loss=0.95, sell_price=0.4)
|
||||
|
||||
energy_system = EnergySystem(pv_type=pv, ess_type=ess, grid_type=grid)
|
||||
|
||||
time_interval = 15 / 60
|
||||
benefit = energy_system.simulate(data=data, time_interval=time_interval)
|
||||
|
||||
print(benefit)
|
Loading…
Reference in New Issue
Block a user