Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RCT/JDJ/5-23 logic correction #1655

Merged
merged 3 commits into from
Mar 2, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions docs/section5/Rule5-23.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:**

Expand Down
50 changes: 8 additions & 42 deletions rct229/rulesets/ashrae9012019/section5/section5rule23.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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__(
Expand All @@ -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(
Expand All @@ -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"
Expand Down
Loading