Skip to content

Commit

Permalink
Merge pull request #56 from pnnl/VAV_turndown_using_average
Browse files Browse the repository at this point in the history
(2nd) VAV turndown lib item development
  • Loading branch information
leijerry888 authored Nov 8, 2024
2 parents ba522bd + 66c2b51 commit 53d20aa
Show file tree
Hide file tree
Showing 4 changed files with 225 additions and 0 deletions.
2 changes: 2 additions & 0 deletions constrain/library/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .heat_rejection_fan_var_flow_controls_cells import *
from .hot_water_reset import *
from .vav_static_pressure_sensor_location import *
from .vav_turndown_during_reheat import *
from .ventilation_fan_controls import *
from .wlhp_loop_heat_rejection_controls import *
from .supply_air_temp_reset import *
Expand Down Expand Up @@ -67,6 +68,7 @@
# "optimum_start", # missing
# "swh_restroom_outlet_maximum_temperature_controls", # missing
"VAVStaticPressureSensorLocation",
"VAVTurndownDuringReheat",
"VentilationFanControl",
"WLHPLoopHeatRejectionControl",
"SupplyAirTempReset",
Expand Down
67 changes: 67 additions & 0 deletions constrain/library/vav_turndown_during_reheat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
"""
### Description
When a VAV box is in reheat mode, the ratio of V_dot_VAV to V_dot_VAV_max should be higher than when it isn't in reheat mode
### Code requirement
- Code Name: ASHRAE 90.1
- Code Year: 2016
- Code Section: 6.5.2 Simultaneous Heating and Cooling Limitation
- Code Subsection: 6.5.2.1 Zone Controls
### Verification Approach
- We aim to identify how VAV airflow rate varies when the VAV box is and isn't in reheat mode.
### Verification logic
```
if (reheat_coil_flag == False).all():
Untested
else:
V_dot_VAV_ratio = V_dot_VAV/V_dot_VAV_max
mean_reheat_ratio = df.loc[self.df[`reheat_coil_flag`], `V_dot_VAV_ratio`].mean()
mean_no_reheat_ratio = df.loc[~self.df[`reheat_coil_flag`], `V_dot_VAV_ratio`].mean()
if mean_reheat_ratio < mean_no_reheat_ratio:
pass
else:
fail
```
### Data requirements
- reheat_coil_flag: VAV box reheat coil operation status
- V_dot_VAV: actual VAV volume flow
- V_dot_VAV_max: max VAV volume flow
"""

from constrain.checklib import RuleCheckBase


class VAVTurndownDuringReheat(RuleCheckBase):
points = [
"reheat_coil_flag",
"V_dot_VAV",
"V_dot_VAV_max",
]

def verify(self):
# Make sure every value in `V_dot_VAV_max` is greater than 0
assert (
self.df["V_dot_VAV_max"] > 0
).all(), "Not all `V_dot_VAV_max` values are greater than 0"

# Check if the `reheat_coil_flag` column has only False values
if (self.df["reheat_coil_flag"] == False).all():
self.df["result"] = "Untested"
else:
self.df["V_dot_VAV_ratio"] = self.df["V_dot_VAV"] / self.df["V_dot_VAV_max"]

# Calculate the mean ratios for reheat and no reheat conditions
mean_reheat_ratio = self.df.loc[
self.df["reheat_coil_flag"], "V_dot_VAV_ratio"
].mean()
mean_no_reheat_ratio = self.df.loc[
~self.df["reheat_coil_flag"], "V_dot_VAV_ratio"
].mean()
self.df["result"] = mean_reheat_ratio < mean_no_reheat_ratio

self.result = self.df["result"]
27 changes: 27 additions & 0 deletions schema/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -1558,5 +1558,32 @@
" pass",
"end"
]
},
"VAVTurndownDuringReheat": {
"library_item_id": 68,
"description_brief": "When a VAV box is in reheat mode, the ratio of V_dot_VAV to V_dot_VAV_max should be higher than when it isn't in reheat mode",
"description_index": [
"Section 6.5.2.1 ASHRAE 90.1-2016"
],
"description_datapoints": {
"reheat_coil_flag": "VAV box reheat coil operation status",
"V_dot_VAV": "VAV airflow rate",
"V_dot_VAV_max": "VAV max airflow rate"
},
"description_verification_type": "procedure-based",
"assertions_type": "pass",
"description_assertions": [
"if (reheat_coil_flag == False).all():",
" Untested",
"else: ",
" V_dot_VAV_ratio = V_dot_VAV/V_dot_VAV_max",
" mean_reheat_ratio = df.loc[self.df[`reheat_coil_flag`], `V_dot_VAV_ratio`].mean()",
" mean_no_reheat_ratio = df.loc[~self.df[`reheat_coil_flag`], `V_dot_VAV_ratio`].mean()",
" if mean_reheat_ratio < mean_no_reheat_ratio:",
" pass",
" else: ",
" fail",
"end"
]
}
}
129 changes: 129 additions & 0 deletions tests/test_vav_turndown_during_reheat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import sys
import unittest

sys.path.append("./constrain")
import datetime

import pandas as pd
from lib_unit_test_runner import *


class TestVAVTurndown(unittest.TestCase):
def test_vav_turndown_during_reheat_pass(self):
points = [
"reheat_coil_flag",
"V_dot_VAV",
"V_dot_VAV_max",
]

timestamp = [
datetime(2024, 8, 1, 12, 0, 0),
datetime(2024, 8, 1, 13, 0, 0),
datetime(2024, 8, 1, 14, 0, 0),
datetime(2024, 8, 1, 15, 0, 0),
]

data = [
[True, 350, 620],
[True, 370, 620],
[False, 360, 620],
[False, 380, 620],
]

df = pd.DataFrame(data, columns=points, index=timestamp)

verification_obj = run_test_verification_with_data(
"VAVTurndownDuringReheat", df
)

results = pd.Series(list(verification_obj.result))
expected_results = pd.Series(
[
True,
True,
True,
True,
]
)
self.assertTrue(results.equals(expected_results))

binary_result = verification_obj.check_bool()
self.assertTrue(binary_result)

def test_vav_turndown_during_reheat_fail(self):
points = [
"reheat_coil_flag",
"V_dot_VAV",
"V_dot_VAV_max",
]

timestamp = [
datetime(2024, 8, 1, 12, 0, 0),
datetime(2024, 8, 1, 13, 0, 0),
datetime(2024, 8, 1, 14, 0, 0),
datetime(2024, 8, 1, 15, 0, 0),
]

data = [
[False, 350, 620],
[False, 370, 620],
[True, 360, 620],
[True, 380, 620],
]

df = pd.DataFrame(data, columns=points, index=timestamp)

verification_obj = run_test_verification_with_data(
"VAVTurndownDuringReheat", df
)

results = pd.Series(list(verification_obj.result))
expected_results = pd.Series(
[
False,
False,
False,
False,
]
)
self.assertTrue(results.equals(expected_results))

binary_result = verification_obj.check_bool()
self.assertFalse(binary_result)

def test_vav_turndown_during_reheat_untested(self):
points = [
"reheat_coil_flag",
"V_dot_VAV",
"V_dot_VAV_max",
]

timestamp = [
datetime(2024, 8, 1, 12, 0, 0),
datetime(2024, 8, 1, 13, 0, 0),
datetime(2024, 8, 1, 14, 0, 0),
datetime(2024, 8, 1, 15, 0, 0),
]

data = [
[False, 350, 620],
[False, 370, 620],
[False, 360, 620],
[False, 380, 620],
]

df = pd.DataFrame(data, columns=points, index=timestamp)

verification_obj = run_test_verification_with_data(
"VAVTurndownDuringReheat", df
)
results = list(verification_obj.result)
expected_results = [
"Untested",
"Untested",
"Untested",
"Untested",
]

self.assertEqual(results, expected_results)
self.assertEqual(verification_obj.check_bool(), "Untested")

0 comments on commit 53d20aa

Please sign in to comment.