Skip to content

Commit

Permalink
Add minimum to power limits.
Browse files Browse the repository at this point in the history
  • Loading branch information
fboundy committed Jul 3, 2024
1 parent cbbeb65 commit 2f7d958
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions apps/pv_opt/pvpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,15 +388,15 @@ def __init__(self, capacity: int, max_dod: float = 0.15, current_limit_amps: int

def __str__(self):
pass

@property
def max_charge_power(self) -> int:
""" returns the maximum watts at which the battery can charge. """
"""returns the maximum watts at which the battery can charge."""
return self.current_limit_amps * self.voltage

@property
def max_discharge_power(self) -> int:
""" returns the maximum watts at which the battery can discharge. """
"""returns the maximum watts at which the battery can discharge."""
return self.max_charge_power


Expand Down Expand Up @@ -925,7 +925,7 @@ def optimised_force(self, initial_soc, static_flows, contract: Contract, **kwarg
str_log += f"SOC: {x.loc[start_window]['soc']:5.1f}%->{x.loc[start_window]['soc_end']:5.1f}% "

forced_charge = min(
self.battery.max_charge_power
min(self.battery.max_charge_power, self.inverter.charger_power)
- x["forced"].loc[start_window]
- x[cols["solar"]].loc[start_window],
((100 - x["soc_end"].loc[start_window]) / 100 * self.battery.capacity) * 2 * factor,
Expand Down Expand Up @@ -1037,7 +1037,8 @@ def optimised_force(self, initial_soc, static_flows, contract: Contract, **kwarg
slot = (
start_window,
-min(
self.battery.max_discharge_power - x[kwargs.get("solar", "solar")].loc[start_window],
min(self.battery.max_discharge_power, self.inverter.inverter_power),
-x[kwargs.get("solar", "solar")].loc[start_window],
((x["soc_end"].loc[start_window] - self.battery.max_dod) / 100 * self.battery.capacity)
* 2
* factor,
Expand Down

0 comments on commit 2f7d958

Please sign in to comment.