wgz_decision/models/module.py

79 lines
2.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

class EC:
def __init__(self, params):
self.current_output = None
self.electricity_efficiency = params['electricity_efficiency']
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.carbon_reduce = params['carbon_reduce']
def step(self, action_ec):
output = self.current_output + action_ec * self.ramp
output = max(self.power_min, min(self.power_max, output)) if output > 0 else 0
self.current_output = output
def get_cost(self, price):
return self.equipment_cost / self.lifetime + price * self.current_output
def get_hydrogen(self):
return self.current_output * self.electricity_efficiency * self.hydrogen_produce
def reset(self):
self.current_output = 0
class HST:
def __init__(self, params):
self.current_capacity = None
self.hydrogen_change = None
self.capacity = params['capacity']
self.min_soc = params['min_soc']
self.max_soc = params['max_soc']
self.degradation = params['degradation']
self.holding = params['holding']
self.ramp = params['ramp']
self.efficiency = params['efficiency']
'''
储氢罐的充气速率 = 电解水制氢速率 (电解水制氢会满足热水需求?
'''
def step(self, action_hst):
energy = action_hst * self.ramp
current_energy = self.current_capacity * self.capacity
updated_capacity = max(self.min_soc, min(self.max_soc, (current_energy + energy) / self.capacity))
self.hydrogen_change = (updated_capacity - self.current_capacity) * self.capacity
self.current_capacity = updated_capacity # update capacity to current state
def get_cost(self, energy_change):
cost = abs(energy_change) * self.degradation
return cost
def SOC(self):
return self.current_capacity
def reset(self):
self.current_capacity = 0.2
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