Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/pnnl/ruleset-checking-tool
Browse files Browse the repository at this point in the history
… into RS/YJ/Rule_12-3
  • Loading branch information
yunjoonjung-PNNL committed Aug 1, 2024
2 parents f934658 + 0ae0ea0 commit f9ff99d
Show file tree
Hide file tree
Showing 131 changed files with 518 additions and 494 deletions.
2 changes: 1 addition & 1 deletion docs/section10/10-7.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
**Rule Assertion:**
- Case 1: if modeled efficiency equals the expected efficiency AND the capacity was defined AND the aggregation factor is either irrelevant or defined, then pass: `if modeled_efficiency_b == expected_baseline_eff_b AND not was_capacity_not_defined and zone_aggregation_factor_undefined_and_needed == FALSE: PASS`
- Case 2: Elif capacity was not defined or and zone_aggregation_factor_undefined_and_needed equal TRUE but the modeled efficiency equals the highest (most conservative) efficiency in the appropriate table based on system type then UNDETERMINED: `elif (was_capacity_not_defined or zone_aggregation_factor_undefined_and_needed == TRUE) AND modeled_efficiency_b == most_conservative_eff == TRUE: UNDETERMINED and raise message "The expected baseline efficiency could not be determined because cooling capacity and/or zone_aggregation_factor were not defined. Check if the modeled baseline DX cooling efficiency was established correctly based upon equipment capacity and type. The modeled efficiency matches the capacity bracket in Appendix G efficiency tables with the highest efficiency (i.e., most conservative efficiency has been modeled)."`
- Case 2: Elif capacity was not defined or zone_aggregation_factor_undefined_and_needed equal TRUE but the modeled efficiency equals the highest (most conservative) efficiency in the appropriate table based on system type then UNDETERMINED: `elif (was_capacity_not_defined or zone_aggregation_factor_undefined_and_needed == TRUE) AND modeled_efficiency_b == most_conservative_eff == TRUE: UNDETERMINED and raise message "The expected baseline efficiency could not be determined because cooling capacity and/or zone_aggregation_factor were not defined. Check if the modeled baseline DX cooling efficiency was established correctly based upon equipment capacity and type. The modeled efficiency matches the capacity bracket in Appendix G efficiency tables with the highest efficiency (i.e., most conservative efficiency has been modeled)."`
- Case 3: Elif capacity was not defined or zone_aggregation_factor_undefined_and_needed equal TRUE and efficiency does not equal the highest (most conservative) efficiency in the appropriate table based on system type then UNDETERMINED: `elif (was_capacity_not_defined or zone_aggregation_factor_undefined_and_needed == TRUE) AND modeled_efficiency_b < most_conservative_eff: UNDETERMINED and raise_message "The expected baseline efficiency could not be determined because cooling capacity and/or zone aggregation factor were not defined. Check if the modeled baseline DX cooling efficiency was established correctly based upon equipment capacity and type."`
- Case 4: Else, fail: `else: FAIL`

Expand Down
22 changes: 11 additions & 11 deletions rct229/rulesets/ashrae9012019/data_fns/extra_schema_fns_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
proposed_equals_user,
)

TEST_RMI = {
TEST_RMD = {
"id": "test_rmd",
"buildings": [
{
Expand Down Expand Up @@ -154,16 +154,16 @@
}


TEST_RMD_FULL = {
TEST_RPD_FULL = {
"id": "229",
"ruleset_model_descriptions": [TEST_RMI],
"ruleset_model_descriptions": [TEST_RMD],
"data_timestamp": "2024-02-12T09:00Z",
}


def test__compare_context_pair__identical():
proposed = TEST_RMD_FULL
user = TEST_RMD_FULL
proposed = TEST_RPD_FULL
user = TEST_RPD_FULL
error_msg_list = []
assert compare_context_pair(
proposed,
Expand All @@ -177,8 +177,8 @@ def test__compare_context_pair__identical():


def test__proposed_equals_user__identical():
proposed = TEST_RMD_FULL
user = TEST_RMD_FULL
proposed = TEST_RPD_FULL
user = TEST_RPD_FULL
error_msg_list = []
assert proposed_equals_user(
index_context=proposed,
Expand All @@ -188,8 +188,8 @@ def test__proposed_equals_user__identical():


def test__compare_context_pair__different():
proposed = TEST_RMD_FULL
user = deepcopy(TEST_RMD_FULL)
proposed = TEST_RPD_FULL
user = deepcopy(TEST_RPD_FULL)
user["ruleset_model_descriptions"][0]["buildings"][0][
"building_open_schedule"
] = "always_1"
Expand All @@ -210,8 +210,8 @@ def test__compare_context_pair__different():


def test__proposed_equals_user__different():
proposed = TEST_RMD_FULL
user = deepcopy(TEST_RMD_FULL)
proposed = TEST_RPD_FULL
user = deepcopy(TEST_RPD_FULL)
user["ruleset_model_descriptions"][0]["buildings"][0][
"building_open_schedule"
] = "always_1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from rct229.schema.validate import schema_validate_rmd
from rct229.utils.assertions import MissingKeyException

TEST_RMI = {
TEST_RMD = {
"id": "test_rmd",
"buildings": [
{
Expand Down Expand Up @@ -144,41 +144,41 @@
}


TEST_RMD = {
TEST_RPD = {
"id": "ASHRAE229",
"ruleset_model_descriptions": [TEST_RMI],
"ruleset_model_descriptions": [TEST_RMD],
"data_timestamp": "2024-02-12T09:00Z",
}


def test__TEST_RMD__is_valid():
schema_validation_result = schema_validate_rmd(TEST_RMD)
def test__TEST_RPD__is_valid():
schema_validation_result = schema_validate_rmd(TEST_RPD)
assert schema_validation_result[
"passed"
], f"Schema error: {schema_validation_result['error']}"


def test__hvac_fan_all_autosized__success():
assert are_all_hvac_sys_fan_objs_autosized(TEST_RMI, "hvac_1") is True
assert are_all_hvac_sys_fan_objs_autosized(TEST_RMD, "hvac_1") is True


def test__hvac_fan_partial_autosized__failed():
assert are_all_hvac_sys_fan_objs_autosized(TEST_RMI, "hvac_2") is False
assert are_all_hvac_sys_fan_objs_autosized(TEST_RMD, "hvac_2") is False


def test__hvac_fan_missing_autosized__exception():
with pytest.raises(MissingKeyException):
are_all_hvac_sys_fan_objs_autosized(TEST_RMI, "hvac_3")
are_all_hvac_sys_fan_objs_autosized(TEST_RMD, "hvac_3")


def test_hvac_fan_all_terminal_autosized__success():
assert are_all_hvac_sys_fan_objs_autosized(TEST_RMI, "hvac_4") is True
assert are_all_hvac_sys_fan_objs_autosized(TEST_RMD, "hvac_4") is True


def test_hvac_fan_all_terminal_fan_partial_autosized__failed():
assert are_all_hvac_sys_fan_objs_autosized(TEST_RMI, "hvac_5") is False
assert are_all_hvac_sys_fan_objs_autosized(TEST_RMD, "hvac_5") is False


def test__hvac_terminal_fan_missing_autosized__exception():
with pytest.raises(MissingKeyException):
are_all_hvac_sys_fan_objs_autosized(TEST_RMI, "hvac_6")
are_all_hvac_sys_fan_objs_autosized(TEST_RMD, "hvac_6")
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
TERMINAL_TYPE = SchemaEnums.schema_enums["TerminalOptions"]


def are_all_terminal_types_VAV(rmd_b, terminal_unit_id_list):
"""Returns TRUE if all of the terminal unit types input to this function are variable air volume (VAV). It returns FALSE if any of the terminal units are of a type other than variable air volume (VAV).
def are_all_terminal_types_VAV(rmd: dict, terminal_unit_id_list: list[str]) -> bool:
"""It returns FALSE if no terminal unit in the list or any of the terminal units are of a type other than variable air volume (VAV) or null.
Parameters
----------
rmd_b : json
rmd : dict
RMD at RuleSetModelDescription level
terminal_unit_id_list : list
List of terminal units IDs
Expand All @@ -20,12 +20,11 @@ def are_all_terminal_types_VAV(rmd_b, terminal_unit_id_list):
True: all of the terminal unit types input to this function are variable air volume (VAV)
False: any of the terminal units are of a type other than variable air volume (VAV)
"""
are_all_terminal_types_VAV_flag = True

for terminal_b_id in terminal_unit_id_list:
terminal_b = find_exactly_one_terminal_unit(rmd_b, terminal_b_id)
if terminal_b.get("type") != TERMINAL_TYPE.VARIABLE_AIR_VOLUME:
are_all_terminal_types_VAV_flag = False
break

return are_all_terminal_types_VAV_flag
return len(terminal_unit_id_list) > 0 and all(
[
find_exactly_one_terminal_unit(rmd, terminal_id).get("type")
in [None, TERMINAL_TYPE.VARIABLE_AIR_VOLUME]
for terminal_id in terminal_unit_id_list
]
)
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from rct229.utils.jsonpath_utils import find_all


def get_dict_with_terminal_units_and_zones(rmi: dict) -> dict:
def get_dict_with_terminal_units_and_zones(rmd: dict) -> dict:
"""
Returns a dictionary of zone IDs associated with each terminal unit in the RMD.
Parameters
----------
rmi: json
rmd: json
Returns ------- dict a dictionary of zones associated with each terminal unit in the rmd, {terminal_unit_1.id: [
zone_1.id, zone_2.id, zone_3.id], terminal_unit_2.id: [zone_4.id, zone_9.id, zone_30.id]}
Expand All @@ -18,9 +18,9 @@ def get_dict_with_terminal_units_and_zones(rmi: dict) -> dict:
# search all zones that have terminal(s) match to this terminal id
# and return them in a list.
f'$.buildings[*].building_segments[*].zones[*][?(@.terminals[*].id="{terminal["id"]}")].id',
rmi,
rmd,
)
for terminal in find_all(
"$.buildings[*].building_segments[*].zones[*].terminals[*]", rmi
"$.buildings[*].building_segments[*].zones[*].terminals[*]", rmd
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"type": "BASELINE_0",
}

TEST_RMD_FULL = {
TEST_RPD_FULL = {
"id": "229_01",
"ruleset_model_descriptions": [TEST_RMD],
"data_timestamp": "2024-02-12T09:00Z",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
"type": "BASELINE_0",
}

TEST_RMD_FULL = {
TEST_RPD_FULL = {
"id": "229_01",
"ruleset_model_descriptions": [TEST_RMD],
"data_timestamp": "2024-02-12T09:00Z",
}


def test__TEST_RMD__is_valid():
schema_validation_result = schema_validate_rmd(TEST_RMD_FULL)
def test__TEST_RPD__is_valid():
schema_validation_result = schema_validate_rmd(TEST_RPD_FULL)
assert schema_validation_result[
"passed"
], f"Schema error: {schema_validation_result['error']}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
"type": "BASELINE_0",
}

TEST_RMD_FULL = {
TEST_RPD_FULL = {
"id": "229_01",
"ruleset_model_descriptions": [TEST_RMD],
"data_timestamp": "2024-02-12T09:00Z",
}


def test__TEST_RMD__is_valid():
schema_validation_result = schema_validate_rmd(TEST_RMD_FULL)
def test__TEST_RPD__is_valid():
schema_validation_result = schema_validate_rmd(TEST_RPD_FULL)
assert schema_validation_result[
"passed"
], f"Schema error: {schema_validation_result['error']}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
"type": "BASELINE_0",
}

TEST_RMD_FULL = {
TEST_RPD_FULL = {
"id": "229_01",
"ruleset_model_descriptions": [TEST_RMD],
"data_timestamp": "2024-02-12T09:00Z",
}


def test__TEST_RMD__is_valid():
schema_validation_result = schema_validate_rmd(TEST_RMD_FULL)
def test__TEST_RPD__is_valid():
schema_validation_result = schema_validate_rmd(TEST_RPD_FULL)
assert schema_validation_result[
"passed"
], f"Schema error: {schema_validation_result['error']}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
"type": "BASELINE_0",
}

TEST_RMD_FULL = {
TEST_RPD_FULL = {
"id": "229_01",
"ruleset_model_descriptions": [TEST_RMD],
"data_timestamp": "2024-02-12T09:00Z",
}


def test__TEST_RMD__is_valid():
schema_validation_result = schema_validate_rmd(TEST_RMD_FULL)
def test__TEST_RPD__is_valid():
schema_validation_result = schema_validate_rmd(TEST_RPD_FULL)
assert schema_validation_result[
"passed"
], f"Schema error: {schema_validation_result['error']}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
"type": "BASELINE_0",
}

TEST_RMD_FULL = {
TEST_RPD_FULL = {
"id": "229_01",
"ruleset_model_descriptions": [TEST_RMD],
"data_timestamp": "2024-02-12T09:00Z",
}


def test__TEST_RMD__is_valid():
schema_validation_result = schema_validate_rmd(TEST_RMD_FULL)
def test__TEST_RPD__is_valid():
schema_validation_result = schema_validate_rmd(TEST_RPD_FULL)
assert schema_validation_result[
"passed"
], f"Schema error: {schema_validation_result['error']}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
"type": "BASELINE_0",
}

TEST_RMD_FULL = {
TEST_RPD_FULL = {
"id": "229_01",
"ruleset_model_descriptions": [TEST_RMD],
"data_timestamp": "2024-02-12T09:00Z",
}


def test__TEST_RMD__is_valid():
schema_validation_result = schema_validate_rmd(TEST_RMD_FULL)
def test__TEST_RPD__is_valid():
schema_validation_result = schema_validate_rmd(TEST_RPD_FULL)
assert schema_validation_result[
"passed"
], f"Schema error: {schema_validation_result['error']}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
"type": "BASELINE_0",
}

TEST_RMD_FULL = {
TEST_RPD_FULL = {
"id": "229_01",
"ruleset_model_descriptions": [TEST_RMD],
"data_timestamp": "2024-02-12T09:00Z",
}


def test__TEST_RMD__is_valid():
schema_validation_result = schema_validate_rmd(TEST_RMD_FULL)
def test__TEST_RPD__is_valid():
schema_validation_result = schema_validate_rmd(TEST_RPD_FULL)
assert schema_validation_result[
"passed"
], f"Schema error: {schema_validation_result['error']}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@
"type": "BASELINE_0",
}

TEST_RMD_FULL = {
TEST_RPD_FULL = {
"id": "229_01",
"ruleset_model_descriptions": [TEST_RMD],
"data_timestamp": "2024-02-12T09:00Z",
}


def test__TEST_RMD__is_valid():
schema_validation_result = schema_validate_rmd(TEST_RMD_FULL)
def test__TEST_RPD__is_valid():
schema_validation_result = schema_validate_rmd(TEST_RPD_FULL)
assert schema_validation_result[
"passed"
], f"Schema error: {schema_validation_result['error']}"
Expand Down
Loading

0 comments on commit f9ff99d

Please sign in to comment.