From d57949012159f328536d7364f668912ed074abf2 Mon Sep 17 00:00:00 2001 From: Cameron Irmas Date: Thu, 28 Dec 2023 15:14:04 -0800 Subject: [PATCH] Fix soc_update to use configured params --- .../simple_battery_dispatch_heuristic.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/hopp/simulation/technologies/dispatch/power_storage/simple_battery_dispatch_heuristic.py b/hopp/simulation/technologies/dispatch/power_storage/simple_battery_dispatch_heuristic.py index c1d03f3cc..61a3ec225 100644 --- a/hopp/simulation/technologies/dispatch/power_storage/simple_battery_dispatch_heuristic.py +++ b/hopp/simulation/technologies/dispatch/power_storage/simple_battery_dispatch_heuristic.py @@ -1,3 +1,5 @@ +from typing import Optional, List, Dict + import pyomo.environ as pyomo from pyomo.environ import units as u @@ -17,9 +19,9 @@ def __init__(self, index_set: pyomo.Set, system_model: BatteryModel.BatteryStateful, financial_model: Singleowner.Singleowner, - fixed_dispatch: list = None, + fixed_dispatch: Optional[List] = None, block_set_name: str = 'heuristic_battery', - dispatch_options: dict = None): + dispatch_options: Optional[Dict] = None): """ :param fixed_dispatch: list of normalized values [-1, 1] (Charging (-), Discharging (+)) @@ -104,16 +106,19 @@ def update_soc(self, power_fraction: float, soc0: float) -> float: Returns: Updated SOC. """ - if power_fraction > 0.1: + if power_fraction > 0.0: discharge_power = power_fraction * self.maximum_power soc = soc0 - self.time_duration[0] * (1/(self.discharge_efficiency/100.) * discharge_power) / self.capacity - elif power_fraction < 0.1: - charge_power = - power_fraction * self.maximum_power + elif power_fraction < 0.0: + charge_power = -power_fraction * self.maximum_power soc = soc0 + self.time_duration[0] * (self.charge_efficiency / 100. * charge_power) / self.capacity else: soc = soc0 - soc = max(0.1, min(0.9, soc)) + min_soc = self._system_model.value("minimum_SOC") + max_soc = self._system_model.value("maximum_SOC") + + soc = max(min_soc, min(max_soc, soc)) return soc