2025-02-11 14:38:52 +08:00
|
|
|
|
class EC:
|
|
|
|
|
def __init__(self, params):
|
2025-02-11 19:12:33 +08:00
|
|
|
|
self.current_power = None
|
2025-02-11 14:38:52 +08:00
|
|
|
|
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']
|
2025-02-11 19:12:33 +08:00
|
|
|
|
self.electricity_efficiency = params['electricity_efficiency']
|
2025-02-11 14:38:52 +08:00
|
|
|
|
self.carbon_reduce = params['carbon_reduce']
|
|
|
|
|
|
|
|
|
|
def step(self, action_ec):
|
2025-02-11 19:12:33 +08:00
|
|
|
|
output = self.current_power + action_ec * self.ramp
|
2025-02-11 14:38:52 +08:00
|
|
|
|
output = max(self.power_min, min(self.power_max, output)) if output > 0 else 0
|
2025-02-11 19:12:33 +08:00
|
|
|
|
self.current_power = output
|
2025-02-11 14:38:52 +08:00
|
|
|
|
|
|
|
|
|
def get_cost(self, price):
|
2025-02-11 19:12:33 +08:00
|
|
|
|
# 成本 = 设备费用 / 生命周期 * 电价 * (用电量 / 最大用电量)
|
|
|
|
|
return self.equipment_cost / self.lifetime * price * self.current_power / self.power_max
|
2025-02-11 14:38:52 +08:00
|
|
|
|
|
|
|
|
|
def get_hydrogen(self):
|
2025-02-11 19:12:33 +08:00
|
|
|
|
return self.current_power * self.electricity_efficiency * self.hydrogen_produce
|
|
|
|
|
|
|
|
|
|
def get_carbon(self):
|
|
|
|
|
return self.current_power * self.carbon_reduce
|
2025-02-11 14:38:52 +08:00
|
|
|
|
|
|
|
|
|
def reset(self):
|
2025-02-11 19:12:33 +08:00
|
|
|
|
self.current_power = 0
|
2025-02-11 14:38:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class HST:
|
|
|
|
|
def __init__(self, params):
|
2025-02-11 19:12:33 +08:00
|
|
|
|
self.current_soc = None
|
2025-02-11 14:38:52 +08:00
|
|
|
|
self.hydrogen_change = None
|
|
|
|
|
self.capacity = params['capacity']
|
|
|
|
|
self.min_soc = params['min_soc']
|
|
|
|
|
self.max_soc = params['max_soc']
|
|
|
|
|
self.ramp = params['ramp']
|
2025-02-11 19:12:33 +08:00
|
|
|
|
self.lifetime = params['lifetime']
|
|
|
|
|
self.equipment_cost = params['equipment_cost']
|
2025-02-11 14:38:52 +08:00
|
|
|
|
self.efficiency = params['efficiency']
|
|
|
|
|
|
|
|
|
|
'''
|
2025-02-11 19:12:33 +08:00
|
|
|
|
储氢罐的充气速率 = 电解水制氢速率 (电解水制氢放的热会满足热水需求?)
|
|
|
|
|
|
|
|
|
|
储氢罐的放气速率 = 供电 (电价低时多电解,电价高时释放)
|
2025-02-11 14:38:52 +08:00
|
|
|
|
'''
|
|
|
|
|
def step(self, action_hst):
|
|
|
|
|
energy = action_hst * self.ramp
|
2025-02-11 19:12:33 +08:00
|
|
|
|
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
|
2025-02-11 14:38:52 +08:00
|
|
|
|
|
2025-02-11 19:12:33 +08:00
|
|
|
|
def get_cost(self):
|
|
|
|
|
cost = self.equipment_cost / self.lifetime * abs(self.hydrogen_change)
|
2025-02-11 14:38:52 +08:00
|
|
|
|
return cost
|
|
|
|
|
|
|
|
|
|
def reset(self):
|
2025-02-11 19:12:33 +08:00
|
|
|
|
self.current_soc = 0.1
|
2025-02-11 14:38:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|