Skip to content

Commit

Permalink
get_required_columns method added to faults to print out req cols and…
Browse files Browse the repository at this point in the history
… also update to fault rule 4 to include a min oa ahu operating state. bump new rev and push to pypi also start of new ipynb for example on running rulse individually
  • Loading branch information
bbartling committed Aug 24, 2024
1 parent fbd5479 commit 359be49
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 233 deletions.
26 changes: 22 additions & 4 deletions open_fdd/air_handling_unit/faults/fault_condition_four.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class FaultConditionFour(FaultCondition):
"""Class provides the definitions for Fault Condition 4.
This fault flags excessive operating states on the AHU
if its hunting between heating, econ, econ+mech, and
if it's hunting between heating, econ, econ+mech, and
a mech clg modes. The code counts how many operating
changes in an hour and will throw a fault if there is
excessive OS changes to flag control sys hunting.
Expand All @@ -28,14 +28,18 @@ def __init__(self, dict_):

self.set_attributes(dict_)

# Set required columns specific to this fault condition
# Set required columns, making heating and cooling optional
self.required_columns = [
self.economizer_sig_col,
self.heating_sig_col,
self.cooling_sig_col,
self.supply_vfd_speed_col,
]

# If heating or cooling columns are provided, add them to the required columns
if self.heating_sig_col:
self.required_columns.append(self.heating_sig_col)
if self.cooling_sig_col:
self.required_columns.append(self.cooling_sig_col)

def get_required_columns(self) -> str:
"""Returns a string representation of the required columns."""
return f"Required columns for FaultConditionFour: {', '.join(self.required_columns)}"
Expand All @@ -45,6 +49,12 @@ def apply(self, df: pd.DataFrame) -> pd.DataFrame:
# Ensure all required columns are present
self.check_required_columns(df)

# If the optional columns are not present, create them with all values set to 0.0
if self.heating_sig_col not in df.columns:
df[self.heating_sig_col] = 0.0
if self.cooling_sig_col not in df.columns:
df[self.cooling_sig_col] = 0.0

if self.troubleshoot_mode:
self.troubleshoot_cols(df)

Expand Down Expand Up @@ -100,6 +110,14 @@ def apply(self, df: pd.DataFrame) -> pd.DataFrame:
& (df[self.economizer_sig_col] == self.ahu_min_oa_dpr)
)

# AHU minimum OA mode without heating or cooling (ventilation mode)
df["min_oa_mode_only"] = (
(df[self.heating_sig_col] == 0)
& (df[self.cooling_sig_col] == 0)
& (df[self.supply_vfd_speed_col] > 0)
& (df[self.economizer_sig_col] == self.ahu_min_oa_dpr)
)

# Fill non-finite values with zero or drop them
df = df.fillna(0)

Expand Down
60 changes: 30 additions & 30 deletions open_fdd/air_handling_unit/faults/helper_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,32 +97,32 @@ def process_all_faults(self, df, config_dict):
if self.validate_config(
["DUCT_STATIC_COL", "DUCT_STATIC_SETPOINT_COL", "SUPPLY_VFD_SPEED_COL"]
):
print("fc1 Go!")
print("Info: Running fc1")
fc1 = FaultConditionOne(config_dict)
else:
print("Skipping fc1...")
print("Info: Skipping fc1")

sys.stdout.flush()

fc2 = None
if self.validate_config(
["SUPPLY_VFD_SPEED_COL", "MAT_COL", "OAT_COL", "SAT_COL", "RAT_COL"]
):
print("fc2 Go!")
print("Info: Running fc2 Go!")
fc2 = FaultConditionTwo(config_dict)
else:
print("Skipping fc2...")
print("Info: Skipping fc2")

sys.stdout.flush()

fc3 = None
if self.validate_config(
["SUPPLY_VFD_SPEED_COL", "MAT_COL", "OAT_COL", "SAT_COL", "RAT_COL"]
):
print("fc3 Go!")
print("Info: Running fc3 Go!")
fc3 = FaultConditionThree(config_dict)
else:
print("Skipping fc3...")
print("Info: Skipping fc3")

sys.stdout.flush()

Expand All @@ -135,21 +135,21 @@ def process_all_faults(self, df, config_dict):
"ECONOMIZER_SIG_COL",
]
):
print("fc4 Go!")
print("Info: Running fc4 Go!")
fc4 = FaultConditionFour(config_dict)
else:
print("Skipping fc4...")
print("Info: Skipping fc4")

sys.stdout.flush()

fc5 = None
if self.validate_config(
["SUPPLY_VFD_SPEED_COL", "HEATING_SIG_COL", "SAT_COL", "MAT_COL"]
):
print("fc5 Go!")
print("Info: Running fc5 Go!")
fc5 = FaultConditionFive(config_dict)
else:
print("Skipping fc5...")
print("Info: Skipping fc5")

sys.stdout.flush()

Expand All @@ -163,21 +163,21 @@ def process_all_faults(self, df, config_dict):
"SUPPLY_FAN_AIR_VOLUME_COL",
]
):
print("fc6 Go!")
print("Info: Running fc6 Go!")
fc6 = FaultConditionSix(config_dict)
else:
print("Skipping fc6...")
print("Info: Skipping fc6")

sys.stdout.flush()

fc7 = None
if self.validate_config(
["SUPPLY_VFD_SPEED_COL", "SAT_COL", "SAT_SETPOINT_COL", "HEATING_SIG_COL"]
):
print("fc7 Go!")
print("Info: Running fc7 Go!")
fc7 = FaultConditionSeven(config_dict)
else:
print("Skipping fc7...")
print("Info: Skipping fc7")

sys.stdout.flush()

Expand All @@ -191,10 +191,10 @@ def process_all_faults(self, df, config_dict):
"SAT_COL",
]
):
print("fc8 Go!")
print("Info: Running fc8 Go!")
fc8 = FaultConditionEight(config_dict)
else:
print("Skipping fc8...")
print("Info: Skipping fc8")

sys.stdout.flush()

Expand All @@ -209,10 +209,10 @@ def process_all_faults(self, df, config_dict):
"ECONOMIZER_SIG_COL",
]
):
print("fc9 Go!")
print("Info: Running fc9 Go!")
fc9 = FaultConditionNine(config_dict)
else:
print("Skipping fc9...")
print("Info: Skipping fc9")

sys.stdout.flush()

Expand All @@ -226,10 +226,10 @@ def process_all_faults(self, df, config_dict):
"ECONOMIZER_SIG_COL",
]
):
print("fc10 Go!")
print("Info: Running fc10 Go!")
fc10 = FaultConditionTen(config_dict)
else:
print("Skipping fc10...")
print("Info: Skipping fc10")

sys.stdout.flush()

Expand All @@ -243,10 +243,10 @@ def process_all_faults(self, df, config_dict):
"SAT_SETPOINT_COL",
]
):
print("fc11 Go!")
print("Info: Running fc11 Go!")
fc11 = FaultConditionEleven(config_dict)
else:
print("Skipping fc11...")
print("Info: Skipping fc11")

sys.stdout.flush()

Expand All @@ -260,10 +260,10 @@ def process_all_faults(self, df, config_dict):
"MAT_COL",
]
):
print("fc12 Go!")
print("Info: Running fc12 Go!")
fc12 = FaultConditionTwelve(config_dict)
else:
print("Skipping fc12...")
print("Info: Skipping fc12")

sys.stdout.flush()

Expand All @@ -277,10 +277,10 @@ def process_all_faults(self, df, config_dict):
"SAT_COL",
]
):
print("fc13 Go!")
print("Info: Running fc13 Go!")
fc13 = FaultConditionThirteen(config_dict)
else:
print("Skipping fc13...")
print("Info: Skipping fc13")

sys.stdout.flush()

Expand All @@ -289,10 +289,10 @@ def process_all_faults(self, df, config_dict):
config_dict.get("COOLING_SIG_COL") is not None
and config_dict.get("CLG_COIL_LEAVE_TEMP_COL") is not None
):
print("fc14 Go!")
print("Info: Running fc14 Go!")
fc14 = FaultConditionFourteen(config_dict)
else:
print("Skipping fc14...")
print("Info: Skipping fc14")

sys.stdout.flush()

Expand All @@ -301,10 +301,10 @@ def process_all_faults(self, df, config_dict):
config_dict.get("HTG_COIL_ENTER_TEMP_COL") is not None
and config_dict.get("HTG_COIL_LEAVE_TEMP_COL") is not None
):
print("fc15 Go!")
print("Info: Running fc15 Go!")
fc15 = FaultConditionFifteen(config_dict)
else:
print("Skipping fc15...")
print("Info: Skipping fc15")

sys.stdout.flush()

Expand Down
Loading

0 comments on commit 359be49

Please sign in to comment.