Skip to content

Commit

Permalink
Merge pull request #220 from fboundy/patch
Browse files Browse the repository at this point in the history
Add self.ev flag
  • Loading branch information
fboundy authored Apr 28, 2024
2 parents ea76105 + 390618f commit 90f9bec
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions apps/pv_opt/pv_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ def initialize(self):
# self._estimate_capacity()
self._load_pv_system_model()
self._load_contract()
self.ev = self.get_config("ev_charger") in DEFAULT_CONFIG['ev_charger']['attributes']['options'][1:]
self._check_for_zappi()

if self.get_config("alt_tariffs") is not None:
Expand Down Expand Up @@ -2398,29 +2399,30 @@ def load_consumption(self, start, end):
if (start < time_now) and (end < time_now):
consumption["consumption"] = df.loc[start:end]
else:
df_EV = None # To store EV consumption
df_EV_Total = None # To store EV consumption and Total consumption
dfx = None

if self.get_config("ev_part_of_house_load", True):
self.log("EV charger is seen as house load, so subtracting EV charging from Total consumption")
df_EV_Total = pd.concat(
[ev_power, df], axis=1
) # concatenate total consumption and ev consumption into a single dataframe (as they are different lengths)
df_EV_Total.columns = ["EV", "Total"] # Set column names
df_EV_Total = df_EV_Total.fillna(0) # fill any missing values with 0

# self.log("Attempt to concatenate is")
# self.log(df_EV_Total)
# self.log("Attempt to concatenate is")
# self.log(df_EV_Total.to_string())

df_EV = df_EV_Total["EV"].squeeze() # Extract EV consumption to Series
df_Total = df_EV_Total["Total"].squeeze() # Extract total consumption to Series
df = df_Total - df_EV # Substract EV consumption from Total Consumption

self.log("Result of subtraction is")
self.log(df.to_string())
if self.ev:
df_EV = None # To store EV consumption
df_EV_Total = None # To store EV consumption and Total consumption
dfx = None

if self.get_config("ev_part_of_house_load", False):
self.log("EV charger is seen as house load, so subtracting EV charging from Total consumption")
df_EV_Total = pd.concat(
[ev_power, df], axis=1
) # concatenate total consumption and ev consumption into a single dataframe (as they are different lengths)
df_EV_Total.columns = ["EV", "Total"] # Set column names
df_EV_Total = df_EV_Total.fillna(0) # fill any missing values with 0

# self.log("Attempt to concatenate is")
# self.log(df_EV_Total)
# self.log("Attempt to concatenate is")
# self.log(df_EV_Total.to_string())

df_EV = df_EV_Total["EV"].squeeze() # Extract EV consumption to Series
df_Total = df_EV_Total["Total"].squeeze() # Extract total consumption to Series
df = df_Total - df_EV # Substract EV consumption from Total Consumption

self.log("Result of subtraction is")
self.log(df.to_string())

# Add consumption margin
df = df * (1 + self.get_config("consumption_margin") / 100)
Expand Down

0 comments on commit 90f9bec

Please sign in to comment.