diff --git a/docs/section5/Rule5-23.md b/docs/section5/Rule5-23.md index 808585da95..2d8e971b71 100644 --- a/docs/section5/Rule5-23.md +++ b/docs/section5/Rule5-23.md @@ -25,25 +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` - - 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 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..fe5ed0c231 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,77 +28,34 @@ 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(), + list_path="$.building_segments[*].zones[*].surfaces[*].subsurfaces[*]", + each_rule=Section5Rule23.BuildingRule.SubsurfaceRule(), index_rmd=BASELINE_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, - # Make sure subsurfaces are matched - # List_path will be evaluated after manual check - list_path="subsurfaces[*]", - manual_check_required_msg=MANUAL_CHECK_MSG, + required_fields={"$": ["has_manual_interior_shades"]}, ) - 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 + def get_calc_vals(self, context, data=None): + subsurface_b = context.BASELINE_0 + subsurface_p = context.PROPOSED return { - "proposed_subsurface_manual_shade": subsurfaces_with_manual_interior_shades_p[ - 0 - ][ + "subsurface_p_manual_shade": subsurface_p[ + "has_manual_interior_shades" + ], + "subsurface_b_manual_shade": subsurface_b[ "has_manual_interior_shades" - ] - if subsurfaces_with_manual_interior_shades_p - else None, + ], } - 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 - return { - "subsurface_p_manual_shade": data[ - "proposed_subsurface_manual_shade" - ], - "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 rule_check(self, context, calc_vals=None, data=None): + return ( + calc_vals["subsurface_p_manual_shade"] + == calc_vals["subsurface_b_manual_shade"] + )