81 lines
2.9 KiB
Python
81 lines
2.9 KiB
Python
class EC:
|
||
def __init__(self, params):
|
||
self.current_power = None
|
||
self.hydrogen_produce = params['hydrogen_produce']
|
||
self.power_max = params['power_max']
|
||
self.power_min = params['power_min']
|
||
self.ramp = params['ramp']
|
||
self.lifetime = params['lifetime']
|
||
self.equipment_cost = params['equipment_cost']
|
||
self.electricity_efficiency = params['electricity_efficiency']
|
||
self.carbon_reduce = params['carbon_reduce']
|
||
|
||
def step(self, action_ec):
|
||
output = self.current_power + action_ec * self.ramp
|
||
output = max(self.power_min, min(self.power_max, output)) if output > 0 else 0
|
||
self.current_power = output
|
||
|
||
def get_cost(self, price):
|
||
# 成本 = 设备费用 / 生命周期 * 电价 * (用电量 / 最大用电量)
|
||
return self.equipment_cost / self.lifetime * price * self.current_power / self.power_max
|
||
|
||
def get_hydrogen(self):
|
||
return self.current_power * self.electricity_efficiency * self.hydrogen_produce
|
||
|
||
def get_carbon(self):
|
||
return self.current_power * self.carbon_reduce
|
||
|
||
def reset(self):
|
||
self.current_power = 0
|
||
|
||
|
||
class HST:
|
||
def __init__(self, params):
|
||
self.current_soc = None
|
||
self.hydrogen_change = None
|
||
self.capacity = params['capacity']
|
||
self.min_soc = params['min_soc']
|
||
self.max_soc = params['max_soc']
|
||
self.ramp = params['ramp']
|
||
self.lifetime = params['lifetime']
|
||
self.equipment_cost = params['equipment_cost']
|
||
self.efficiency = params['efficiency']
|
||
|
||
'''
|
||
储氢罐的充气速率 = 电解水制氢速率 (电解水制氢放的热会满足热水需求?)
|
||
|
||
储氢罐的放气速率 = 供电 (电价低时多电解,电价高时释放)
|
||
'''
|
||
def step(self, action_hst):
|
||
energy = action_hst * self.ramp
|
||
updated_soc = max(self.min_soc, min(self.max_soc, (self.current_soc * self.capacity + energy) / self.capacity))
|
||
self.hydrogen_change = (updated_capacity - self.current_soc) * self.capacity
|
||
self.current_soc = updated_soc
|
||
|
||
def get_cost(self):
|
||
cost = self.equipment_cost / self.lifetime * abs(self.hydrogen_change)
|
||
return cost
|
||
|
||
def reset(self):
|
||
self.current_soc = 0.1
|
||
|
||
|
||
class Grid:
|
||
def __init__(self):
|
||
self.delta = 1
|
||
self.exchange_ability = 100
|
||
|
||
def get_cost(self, current_price, energy_exchange):
|
||
return current_price * energy_exchange * self.delta
|
||
|
||
def retrieve_past_price(self):
|
||
result = []
|
||
# 过去24小时的价格起始、结束索引
|
||
start_index = max(0, 24 * (self.day - 1) + self.time - 24)
|
||
end_index = 24 * (self.day - 1) + self.time
|
||
past_price = self.price[start_index:end_index]
|
||
result.extend(past_price)
|
||
# current_day_price = self.price[24 * self.day:24 * self.day + self.time]
|
||
# result.extend(current_day_price)
|
||
return result
|