From dc1b5bac7a890ea27ddde50ddfdcc47faef209b8 Mon Sep 17 00:00:00 2001 From: Jackson Jarboe <122476654+JacksonJ-KC@users.noreply.github.com> Date: Wed, 19 Feb 2025 14:10:15 -0500 Subject: [PATCH 1/3] suggestions to correct logic --- docs/section5/Rule5-23.md | 14 +----- .../ashrae9012019/section5/section5rule23.py | 50 +++---------------- 2 files changed, 10 insertions(+), 54 deletions(-) diff --git a/docs/section5/Rule5-23.md b/docs/section5/Rule5-23.md index 808585da95..97f9e79b60 100644 --- a/docs/section5/Rule5-23.md +++ b/docs/section5/Rule5-23.md @@ -29,21 +29,11 @@ - For each subsurface in surface in P_RMD: `for subsurface_p in surface_p.subsurfaces:` - - Calculate the total number of subsurfaces that have manual shades modeled: `if subsurface_p.has_manual_interior_shades: num_shades += 1` - - - Check if subsurfaces in P_RMD have different manual shade status, flag for manual check: `if ( num_shades != LEN(surface_p.subsurfaces) ) AND ( num_shades != 0 ): manual_check_flag = TRUE` - - - Else, for each subsurface in surface in B_RMD: `else: for subsurface_b in surface_b.subsurfaces:` - - - Check if subsurface is modeled with the same manual shade status as in P_RMD: `if subsurface_b.has_manual_interior_shades == surface_p.subsurfaces[0].has_manual_interior_shades: shade_match_flag = TRUE` - **Rule Assertion:** - - Case 1: For each surface, if manual check flag is True: `if manual_check_flag: CAUTION and raise_warning "SURFACE IN P-RMD HAS SUBSURFACES MODELED WITH DIFFERENT MANUAL SHADE STATUS. VERIFY IF SUBSURFACES MANUAL SHADE STATUS IN B-RMD ARE MODELED THE SAME AS IN P-RMD".` - - - Case 2: Else if shade_match_flag is True: `if shade_match_flag: PASS` + - Case 1: If subsurface is modeled with the same manual shade status as in P_RMD: `if subsurface_b.has_manual_interior_shades == subsurface_p.has_manual_interior_shades: PASS` - - Case 3: Else: `else: FAIL` + - Case 2: Else: `else: FAIL` **Notes:** diff --git a/rct229/rulesets/ashrae9012019/section5/section5rule23.py b/rct229/rulesets/ashrae9012019/section5/section5rule23.py index 242df1c37b..0d90b40f77 100644 --- a/rct229/rulesets/ashrae9012019/section5/section5rule23.py +++ b/rct229/rulesets/ashrae9012019/section5/section5rule23.py @@ -2,15 +2,6 @@ from rct229.rule_engine.rule_list_indexed_base import RuleDefinitionListIndexedBase from rct229.rule_engine.ruleset_model_factory import produce_ruleset_model_description from rct229.rulesets.ashrae9012019 import BASELINE_0 -from rct229.utils.jsonpath_utils import find_all -from rct229.utils.std_comparisons import std_equal - -MANUAL_CHECK_MSG = "Surface in P-RMD has subsurfaces modeled with different manual shade status. Verify if subsurfaces manual shade status in B-RMD are modeled the same as in P-RMD" - -# Json path for subsurfaces with has_manual_interior_shades set to True -MANUALLY_SHADED_SUBSURFACES_JSON = ( - "$.subsurfaces[*][?(@.has_manual_interior_shades=true)]" -) class Section5Rule23(RuleDefinitionListIndexedBase): @@ -37,12 +28,16 @@ def __init__(self): rmds_used=produce_ruleset_model_description( USER=False, BASELINE_0=True, PROPOSED=True ), - # Make sure surfaces are matched in SurfaceRule list_path="$.building_segments[*].zones[*].surfaces[*]", each_rule=Section5Rule23.BuildingRule.SurfaceRule(), index_rmd=BASELINE_0, ) + def list_filter(self, context_item, data): + surface_b = context_item.BASELINE_0 + subsurfaces_b = surface_b.get("subsurfaces", []) + return len(subsurfaces_b) > 0 + class SurfaceRule(RuleDefinitionListIndexedBase): def __init__(self): super(Section5Rule23.BuildingRule.SurfaceRule, self).__init__( @@ -51,39 +46,9 @@ def __init__(self): ), each_rule=Section5Rule23.BuildingRule.SurfaceRule.SubsurfaceRule(), index_rmd=BASELINE_0, - # Make sure subsurfaces are matched - # List_path will be evaluated after manual check list_path="subsurfaces[*]", - manual_check_required_msg=MANUAL_CHECK_MSG, - ) - - def manual_check_required(self, context, calc_vals=None, data=None): - surface_p = context.PROPOSED - subsurfaces_p = find_all("$.subsurfaces[*]", surface_p) - subsurfaces_with_manual_interior_shades_p = find_all( - MANUALLY_SHADED_SUBSURFACES_JSON, surface_p ) - return len(subsurfaces_with_manual_interior_shades_p) != 0 and len( - subsurfaces_with_manual_interior_shades_p - ) != len(subsurfaces_p) - - def create_data(self, context, data=None): - surface_p = context.PROPOSED - subsurfaces_with_manual_interior_shades_p = find_all( - MANUALLY_SHADED_SUBSURFACES_JSON, surface_p - ) - # None - if no subsurfaces, then the code wont evaluate the subsurface rule - return { - "proposed_subsurface_manual_shade": subsurfaces_with_manual_interior_shades_p[ - 0 - ][ - "has_manual_interior_shades" - ] - if subsurfaces_with_manual_interior_shades_p - else None, - } - class SubsurfaceRule(RuleDefinitionBase): def __init__(self): super( @@ -97,9 +62,10 @@ def __init__(self): def get_calc_vals(self, context, data=None): subsurface_b = context.BASELINE_0 + subsurface_p = context.PROPOSED return { - "subsurface_p_manual_shade": data[ - "proposed_subsurface_manual_shade" + "subsurface_p_manual_shade": subsurface_p[ + "has_manual_interior_shades" ], "subsurface_b_manual_shade": subsurface_b[ "has_manual_interior_shades" From 8d10adde5ddda788a0c38bbae3eefacabadb7a10 Mon Sep 17 00:00:00 2001 From: Jackson Jarboe <122476654+JacksonJ-KC@users.noreply.github.com> Date: Fri, 28 Feb 2025 10:32:06 -0500 Subject: [PATCH 2/3] review updates --- docs/section5/Rule5-23.md | 14 ++-- .../ashrae9012019/section5/section5rule23.py | 64 +++++++------------ 2 files changed, 31 insertions(+), 47 deletions(-) diff --git a/docs/section5/Rule5-23.md b/docs/section5/Rule5-23.md index 97f9e79b60..2d8e971b71 100644 --- a/docs/section5/Rule5-23.md +++ b/docs/section5/Rule5-23.md @@ -25,15 +25,15 @@ - For each surface in zone: `for surface_b in zone_b.surfaces:` - - Get matching surface in P_RMD: `surface_p = match_data_element(P_RMD, Surfaces, surface_b.id)` + - For each subsurface in surface in B_RMD: `for subsurface_b in surface_b.subsurfaces:` + + - Get matching subsurface in P_RMD: subsurface_p = match_data_element(P_RMD, Subsurfaces, subsurface_b.id) + + - **Rule Assertion:** - - For each subsurface in surface in P_RMD: `for subsurface_p in surface_p.subsurfaces:` + - Case 1: If subsurface is modeled with the same manual shade status as in P_RMD: `if subsurface_b.has_manual_interior_shades == subsurface_p.has_manual_interior_shades: PASS` - **Rule Assertion:** - - - Case 1: If subsurface is modeled with the same manual shade status as in P_RMD: `if subsurface_b.has_manual_interior_shades == subsurface_p.has_manual_interior_shades: PASS` - - - Case 2: Else: `else: FAIL` + - Case 2: Else: `else: FAIL` **Notes:** diff --git a/rct229/rulesets/ashrae9012019/section5/section5rule23.py b/rct229/rulesets/ashrae9012019/section5/section5rule23.py index 0d90b40f77..734c43cf99 100644 --- a/rct229/rulesets/ashrae9012019/section5/section5rule23.py +++ b/rct229/rulesets/ashrae9012019/section5/section5rule23.py @@ -28,52 +28,36 @@ def __init__(self): rmds_used=produce_ruleset_model_description( USER=False, BASELINE_0=True, PROPOSED=True ), - list_path="$.building_segments[*].zones[*].surfaces[*]", - each_rule=Section5Rule23.BuildingRule.SurfaceRule(), + list_path="$.building_segments[*].zones[*].surfaces[*].subsurfaces[*]", + each_rule=Section5Rule23.BuildingRule.SubsurfaceRule(), index_rmd=BASELINE_0, ) - def list_filter(self, context_item, data): - surface_b = context_item.BASELINE_0 - subsurfaces_b = surface_b.get("subsurfaces", []) - return len(subsurfaces_b) > 0 - - class SurfaceRule(RuleDefinitionListIndexedBase): + class SubsurfaceRule(RuleDefinitionBase): def __init__(self): - super(Section5Rule23.BuildingRule.SurfaceRule, self).__init__( + super( + Section5Rule23.BuildingRule.SubsurfaceRule, self + ).__init__( rmds_used=produce_ruleset_model_description( USER=False, BASELINE_0=True, PROPOSED=True ), - each_rule=Section5Rule23.BuildingRule.SurfaceRule.SubsurfaceRule(), - index_rmd=BASELINE_0, - list_path="subsurfaces[*]", + required_fields={"$": ["has_manual_interior_shades"]}, ) - class SubsurfaceRule(RuleDefinitionBase): - def __init__(self): - super( - Section5Rule23.BuildingRule.SurfaceRule.SubsurfaceRule, self - ).__init__( - rmds_used=produce_ruleset_model_description( - USER=False, BASELINE_0=True, PROPOSED=True - ), - required_fields={"$": ["has_manual_interior_shades"]}, - ) - - def get_calc_vals(self, context, data=None): - subsurface_b = context.BASELINE_0 - subsurface_p = context.PROPOSED - return { - "subsurface_p_manual_shade": subsurface_p[ - "has_manual_interior_shades" - ], - "subsurface_b_manual_shade": subsurface_b[ - "has_manual_interior_shades" - ], - } - - def rule_check(self, context, calc_vals=None, data=None): - return ( - calc_vals["subsurface_p_manual_shade"] - == calc_vals["subsurface_b_manual_shade"] - ) + def get_calc_vals(self, context, data=None): + subsurface_b = context.BASELINE_0 + subsurface_p = context.PROPOSED + return { + "subsurface_p_manual_shade": subsurface_p[ + "has_manual_interior_shades" + ], + "subsurface_b_manual_shade": subsurface_b[ + "has_manual_interior_shades" + ], + } + + def rule_check(self, context, calc_vals=None, data=None): + return ( + calc_vals["subsurface_p_manual_shade"] + == calc_vals["subsurface_b_manual_shade"] + ) From 40e4ce8f74882d34775d2ccc10e8d5649d96c660 Mon Sep 17 00:00:00 2001 From: Jackson Jarboe <122476654+JacksonJ-KC@users.noreply.github.com> Date: Fri, 28 Feb 2025 10:33:25 -0500 Subject: [PATCH 3/3] black --- rct229/rulesets/ashrae9012019/section5/section5rule23.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rct229/rulesets/ashrae9012019/section5/section5rule23.py b/rct229/rulesets/ashrae9012019/section5/section5rule23.py index 734c43cf99..fe5ed0c231 100644 --- a/rct229/rulesets/ashrae9012019/section5/section5rule23.py +++ b/rct229/rulesets/ashrae9012019/section5/section5rule23.py @@ -35,9 +35,7 @@ def __init__(self): class SubsurfaceRule(RuleDefinitionBase): def __init__(self): - super( - Section5Rule23.BuildingRule.SubsurfaceRule, self - ).__init__( + super(Section5Rule23.BuildingRule.SubsurfaceRule, self).__init__( rmds_used=produce_ruleset_model_description( USER=False, BASELINE_0=True, PROPOSED=True ),