mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-08-25 15:01:14 +00:00
Battery SoC = 0 > set Discharge randomply to 0/1. For longer periods of storage (#366)
* Battery SoC = 0 > hard Discharge Setting Off
This commit is contained in:
@@ -442,29 +442,41 @@ class optimization_problem(ConfigMixin, DevicesMixin, EnergyManagementSystemMixi
|
||||
individual[:] = adjusted_individual
|
||||
|
||||
# New check: Activate discharge when battery SoC is 0
|
||||
battery_soc_per_hour = np.array(
|
||||
o.get("akku_soc_pro_stunde", [])
|
||||
) # Example key for battery SoC
|
||||
# battery_soc_per_hour = np.array(
|
||||
# o.get("akku_soc_pro_stunde", [])
|
||||
# ) # Example key for battery SoC
|
||||
|
||||
if battery_soc_per_hour is not None:
|
||||
if battery_soc_per_hour is None or discharge_hours_bin is None:
|
||||
raise ValueError("battery_soc_per_hour or discharge_hours_bin is None")
|
||||
min_length = min(battery_soc_per_hour.size, discharge_hours_bin.size)
|
||||
battery_soc_per_hour_tail = battery_soc_per_hour[-min_length:]
|
||||
discharge_hours_bin_tail = discharge_hours_bin[-min_length:]
|
||||
len_ac = len(self.config.optimization_ev_available_charge_rates_percent)
|
||||
# if battery_soc_per_hour is not None:
|
||||
# if battery_soc_per_hour is None or discharge_hours_bin is None:
|
||||
# raise ValueError("battery_soc_per_hour or discharge_hours_bin is None")
|
||||
# min_length = min(battery_soc_per_hour.size, discharge_hours_bin.size)
|
||||
# battery_soc_per_hour_tail = battery_soc_per_hour[-min_length:]
|
||||
# discharge_hours_bin_tail = discharge_hours_bin[-min_length:]
|
||||
# len_ac = len(self.config.optimization_ev_available_charge_rates_percent)
|
||||
|
||||
# Find hours where battery SoC is 0
|
||||
zero_soc_mask = battery_soc_per_hour_tail == 0
|
||||
discharge_hours_bin_tail[zero_soc_mask] = (
|
||||
len_ac + 2
|
||||
) # Activate discharge for these hours
|
||||
# # # Find hours where battery SoC is 0
|
||||
# # zero_soc_mask = battery_soc_per_hour_tail == 0
|
||||
# # discharge_hours_bin_tail[zero_soc_mask] = (
|
||||
# # len_ac + 2
|
||||
# # ) # Activate discharge for these hours
|
||||
|
||||
# Merge the updated discharge_hours_bin back into the individual
|
||||
adjusted_individual = self.merge_individual(
|
||||
discharge_hours_bin, eautocharge_hours_index, washingstart_int
|
||||
)
|
||||
individual[:] = adjusted_individual
|
||||
# # When Battery SoC then set the Discharge randomly to 0 or 1. otherwise it's very unlikely to get a state where a battery can store energy for a longer time
|
||||
# # Find hours where battery SoC is 0
|
||||
# zero_soc_mask = battery_soc_per_hour_tail == 0
|
||||
# # discharge_hours_bin_tail[zero_soc_mask] = (
|
||||
# # len_ac + 2
|
||||
# # ) # Activate discharge for these hours
|
||||
# set_to_len_ac_plus_2 = np.random.rand() < 0.5 # True mit 50% Wahrscheinlichkeit
|
||||
|
||||
# # Werte setzen basierend auf der zufälligen Entscheidung
|
||||
# value_to_set = len_ac + 2 if set_to_len_ac_plus_2 else 0
|
||||
# discharge_hours_bin_tail[zero_soc_mask] = value_to_set
|
||||
|
||||
# # Merge the updated discharge_hours_bin back into the individual
|
||||
# adjusted_individual = self.merge_individual(
|
||||
# discharge_hours_bin, eautocharge_hours_index, washingstart_int
|
||||
# )
|
||||
# individual[:] = adjusted_individual
|
||||
|
||||
# More metrics
|
||||
individual.extra_data = ( # type: ignore[attr-defined]
|
||||
|
Reference in New Issue
Block a user