From c7bba66a498f9d09e721d54287a2b7b8cfbf982f Mon Sep 17 00:00:00 2001 From: stevebuk1 <78320816+stevebuk1@users.noreply.github.com> Date: Tue, 29 Oct 2024 16:49:25 +0000 Subject: [PATCH] Bugfix - factoring code applied twice. --- apps/pv_opt/pvpy.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/apps/pv_opt/pvpy.py b/apps/pv_opt/pvpy.py index bddcd54..0758ec6 100644 --- a/apps/pv_opt/pvpy.py +++ b/apps/pv_opt/pvpy.py @@ -1058,11 +1058,23 @@ def optimised_force(self, initial_soc, static_flows, contract: Contract, **kwarg # Each slot is assigned a value of 1, if already in a slot then factor for time already gone. - for slot in window: - factors.append(1) + + #self.log("Time logging") + #self.log(f"Timenow = {pd.Timestamp.utcnow().tz_localize(None)}") + + #Test: Code for not doing factoring if in a partial slot + #for slot in window: + # factors.append(1) for slot in window: + if log: + self.log(f"Slot time = {slot.tz_localize(None)}") if pd.Timestamp.utcnow().tz_localize(None) > slot.tz_localize(None): + #if log: + # self.log("Partial slot detected") + # self.log("Factor to be written is....") + # self.log(((slot.tz_localize(None) + pd.Timedelta(30, 'minutes')) - pd.Timestamp.utcnow().tz_localize(None)).total_seconds() / 1800) + factors.append( ( (slot.tz_localize(None) + pd.Timedelta(30, "minutes")) @@ -1077,8 +1089,9 @@ def optimised_force(self, initial_soc, static_flows, contract: Contract, **kwarg factors = [f / sum(factors) for f in factors] - # self.log("Factors =") - # self.log(factors) + #if log: + # self.log("Factors =") + # self.log(factors) # The reduction of the current slot reduces the power so the .flows algorithm calculates the correct charge added to the battery in the partial slot. # However, this same value should not then be used to program the inverter. The inverter should stick at the power assigned at the start of the slot.