-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #262 from camirmas/load_following_heuristic
Load following heuristic
- Loading branch information
Showing
9 changed files
with
250 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
hopp/simulation/technologies/dispatch/power_storage/heuristic_load_following_dispatch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from typing import Optional, List | ||
|
||
import pyomo.environ as pyomo | ||
from pyomo.environ import units as u | ||
import PySAM.BatteryStateful as BatteryModel | ||
import PySAM.Singleowner as Singleowner | ||
|
||
from hopp.simulation.technologies.dispatch.power_storage.simple_battery_dispatch_heuristic import SimpleBatteryDispatchHeuristic | ||
|
||
|
||
class HeuristicLoadFollowingDispatch(SimpleBatteryDispatchHeuristic): | ||
"""Operates the battery based on heuristic rules to meet the demand profile based power available from power generation profiles and | ||
power demand profile. | ||
Currently, enforces available generation and grid limit assuming no battery charging from grid | ||
""" | ||
def __init__(self, | ||
pyomo_model: pyomo.ConcreteModel, | ||
index_set: pyomo.Set, | ||
system_model: BatteryModel.BatteryStateful, | ||
financial_model: Singleowner.Singleowner, | ||
fixed_dispatch: Optional[List] = None, | ||
block_set_name: str = 'heuristic_load_following_battery', | ||
dispatch_options: Optional[dict] = None): | ||
""" | ||
Args: | ||
fixed_dispatch: list of normalized values [-1, 1] (Charging (-), Discharging (+)) | ||
""" | ||
super().__init__( | ||
pyomo_model, | ||
index_set, | ||
system_model, | ||
financial_model, | ||
fixed_dispatch, | ||
block_set_name, | ||
dispatch_options | ||
) | ||
|
||
def set_fixed_dispatch(self, gen: list, grid_limit: list, goal_power: list): | ||
"""Sets charge and discharge power of battery dispatch using fixed_dispatch attribute and enforces available | ||
generation and grid limits. | ||
""" | ||
self.check_gen_grid_limit(gen, grid_limit) | ||
self._set_power_fraction_limits(gen, grid_limit) | ||
self._heuristic_method(gen, goal_power) | ||
self._fix_dispatch_model_variables() | ||
|
||
def _heuristic_method(self, gen, goal_power): | ||
""" Enforces battery power fraction limits and sets _fixed_dispatch attribute | ||
Sets the _fixed_dispatch based on goal_power and gen (power genration profile) | ||
""" | ||
for t in self.blocks.index_set(): | ||
fd = (goal_power[t] - gen[t]) / self.maximum_power | ||
if fd > 0.0: # Discharging | ||
if fd > self.max_discharge_fraction[t]: | ||
fd = self.max_discharge_fraction[t] | ||
elif fd < 0.0: # Charging | ||
if -fd > self.max_charge_fraction[t]: | ||
fd = -self.max_charge_fraction[t] | ||
self._fixed_dispatch[t] = fd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.