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

Develop rct tolerance #1535

Merged
merged 77 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
0875e57
Added is_tolerance_fail method in section 19
yunjoonjung-PNNL Jan 19, 2024
5831710
Added is_tolerance_fail method in section 21
yunjoonjung-PNNL Jan 19, 2024
68cdaaa
Added is_tolerance_fail method in section 22
yunjoonjung-PNNL Jan 19, 2024
2c93eef
Added is_tolerance_fail method in section23
yunjoonjung-PNNL Jan 19, 2024
2c53aec
add is_tolerance_fail for Section 5 and 6
Jiarongx-Xie Jan 22, 2024
12c013b
Revert "add is_tolerance_fail for Section 5 and 6"
Jiarongx-Xie Jan 22, 2024
fb156ac
Addressed PR comments
yunjoonjung-PNNL Jan 22, 2024
0f369d9
is_tolerance_fail method in section 5
Jiarongx-Xie Jan 22, 2024
8054e36
is_tolerance_fail method in section 6
Jiarongx-Xie Jan 22, 2024
ad9d588
address PR comments
Jiarongx-Xie Jan 25, 2024
da4806c
Addressed WX's PR comments
yunjoonjung-PNNL Feb 8, 2024
88299e8
remove is_tolerance_fail when comparing two user input values
Jiarongx-Xie Jan 25, 2024
9f8bbc1
Merge branch 'develop' of https://github.com/pnnl/ruleset-checking-to…
yunjoonjung-PNNL Feb 20, 2024
dfb6c56
Added std_le and std_lt
yunjoonjung-PNNL Feb 20, 2024
a93910d
Merge branch 'develop' of https://github.com/pnnl/ruleset-checking-to…
yunjoonjung-PNNL Feb 26, 2024
a5c49f8
Merge branch 'develop' of https://github.com/pnnl/ruleset-checking-to…
weilixu Mar 7, 2024
e899e7f
Merge branch 'develop_rct_tolerance' of https://github.com/pnnl/rules…
weilixu Mar 7, 2024
ece328a
Merge pull request #1263 from pnnl/section_18_to_23
weilixu Mar 7, 2024
5792847
Merge branch 'develop_rct_tolerance' of https://github.com/pnnl/rules…
weilixu Mar 7, 2024
c04ca4b
Merge branch 'develop' of https://github.com/pnnl/ruleset-checking-to…
weilixu Jun 11, 2024
c45405c
Merge branch 'develop_rct_tolerance' of https://github.com/pnnl/rules…
weilixu Jun 11, 2024
b9cb273
Merge branch 'develop_rct_tolerance' of https://github.com/pnnl/rules…
weilixu Jun 11, 2024
9b683ef
update for 5-8
weilixu Jun 11, 2024
6320057
update rule base to include precision comparison function
weilixu Jun 11, 2024
e8210da
Merge branch 'develop_rct_tolerance' of https://github.com/pnnl/rules…
weilixu Jun 11, 2024
b5be88c
rules before Section 5 Rule 20 (included)
Jiarongx-Xie Jun 17, 2024
2406594
update precision function implementation.
weilixu Jun 17, 2024
ec3270e
format update
weilixu Jun 17, 2024
837b8ac
allow none for unit
weilixu Jun 18, 2024
23e6626
is_tolerance_fail method in section 5
Jiarongx-Xie Jan 22, 2024
62b147a
is_tolerance_fail method in section 6
Jiarongx-Xie Jan 22, 2024
a321026
address PR comments
Jiarongx-Xie Jan 25, 2024
8bccacc
remove is_tolerance_fail when comparing two user input values
Jiarongx-Xie Jan 25, 2024
1537699
update for 5-8
weilixu Jun 11, 2024
891d10b
rules before Section 5 Rule 20 (included)
Jiarongx-Xie Jun 17, 2024
81d6461
update Section 5 1-20
Jiarongx-Xie Jun 25, 2024
964c7f5
fix merge error
Jiarongx-Xie Jun 29, 2024
054bfe6
revert change to rmd
Jiarongx-Xie Jun 29, 2024
aa44519
a workable example 5-4
Jiarongx-Xie Jun 29, 2024
0d1a563
most workable rules
Jiarongx-Xie Jun 29, 2024
8f06682
fix 5-39 typo
Jiarongx-Xie Jul 2, 2024
464574b
fix 5-35
Jiarongx-Xie Jul 2, 2024
dea7f81
fix 5-1, 15
Jiarongx-Xie Jul 2, 2024
c9bbc2a
fix 5-35
Jiarongx-Xie Jul 2, 2024
6df15b1
fix 5-37, format 5-35
Jiarongx-Xie Jul 2, 2024
4515d3a
update 6-1
Jiarongx-Xie Jul 2, 2024
9e69c2b
change to air_flow_rate in CalcQ
Jiarongx-Xie Jul 2, 2024
b2ad376
update 5-15 test json
Jiarongx-Xie Jul 2, 2024
50cf077
remove statements in 5-15
Jiarongx-Xie Jul 2, 2024
336b06e
fix 6-1
Jiarongx-Xie Jul 3, 2024
5e66744
Merge branch 'develop' of https://github.com/pnnl/ruleset-checking-to…
weilixu Sep 3, 2024
0718371
Added decimal precision for section 21
yunjoonjung-PNNL Sep 6, 2024
dc197d3
Updated temp precison to K
yunjoonjung-PNNL Sep 6, 2024
21b67b9
Added decimal point for section 23
yunjoonjung-PNNL Sep 6, 2024
b020f82
Added decimal point for section 18
yunjoonjung-PNNL Sep 6, 2024
ca8f291
Adde decimal point for section 22
yunjoonjung-PNNL Sep 7, 2024
c9ce202
Added decimal point for section 19
yunjoonjung-PNNL Sep 7, 2024
67dd21b
Merge branch 'develop' of https://github.com/pnnl/ruleset-checking-to…
yunjoonjung-PNNL Sep 7, 2024
5e98772
Fixed decimal points
yunjoonjung-PNNL Sep 10, 2024
f11eb01
black formatting
yunjoonjung-PNNL Sep 10, 2024
030a6db
Added precision attr in the RuleDefinitionListBase class
yunjoonjung-PNNL Sep 10, 2024
2815b07
Updated temperature in K precision
yunjoonjung-PNNL Sep 10, 2024
fba7e77
Fixed wrong decimal comparison
yunjoonjung-PNNL Sep 10, 2024
451f75d
Fixed failed rule
yunjoonjung-PNNL Sep 10, 2024
eed6381
Fixed 22-11
yunjoonjung-PNNL Sep 10, 2024
11da631
Fixed is tol fail method
yunjoonjung-PNNL Sep 10, 2024
0044bf6
Added temporary print for CICD debugging
yunjoonjung-PNNL Sep 18, 2024
71e90e3
Temporary: Leave only 19-7-j for debugging
yunjoonjung-PNNL Sep 18, 2024
40d1974
Temporary: Added more vars for print
yunjoonjung-PNNL Sep 18, 2024
9bb0e27
Fixed typo
yunjoonjung-PNNL Sep 18, 2024
d41a5f9
Reverted to original files
yunjoonjung-PNNL Sep 18, 2024
a9cda22
Updated 19-7-j test case
yunjoonjung-PNNL Sep 23, 2024
207358e
Updated 19-7-j
yunjoonjung-PNNL Sep 23, 2024
926ea64
Merge pull request #1521 from pnnl/RCT/YJ/decimal_point_update
weilixu Sep 30, 2024
e6d71c4
Merge branch 'develop_rct_tolerance' of https://github.com/pnnl/rules…
weilixu Sep 30, 2024
53483c3
Merge pull request #1267 from pnnl/is_tolerance_fail_section_5_to_6
weilixu Sep 30, 2024
24bebe8
Merge branch 'develop' of https://github.com/pnnl/ruleset-checking-to…
weilixu Sep 30, 2024
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
6 changes: 5 additions & 1 deletion rct229/rule_engine/partial_rule_definition.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from rct229.rule_engine.rule_base import RuleDefinitionBase
from typing import Mapping

from rct229.rule_engine.rule_base import RCTPrecision, RuleDefinitionBase


class PartialRuleDefinition(RuleDefinitionBase):
Expand All @@ -14,6 +16,7 @@ def __init__(
required_fields=None,
manual_check_required_msg="",
not_applicable_msg="",
precision: Mapping[str, RCTPrecision] = None,
):
"""Base class for all Partial Rule definitions (secondary)
Expand Down Expand Up @@ -58,6 +61,7 @@ def __init__(
ruleset_section_title=ruleset_section_title,
standard_section=standard_section,
is_primary_rule=is_primary_rule,
precision=precision,
)

def rule_check(self, context, calc_vals=None, data={}):
Expand Down
56 changes: 46 additions & 10 deletions rct229/rule_engine/rule_base.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
from functools import partial
from typing import TypedDict, Mapping

from jsonpointer import resolve_pointer
from rct229.rule_engine.rct_outcome_label import RCTOutcomeLabel
from rct229.rule_engine.ruleset_model_factory import RuleSetModels, get_rmd_instance
from rct229.schema.config import ureg
from rct229.utils.assertions import MissingKeyException, RCTFailureException
from rct229.utils.json_utils import slash_prefix_guarantee
from rct229.utils.jsonpath_utils import find_all
from rct229.utils.pint_utils import calcq_to_q
from rct229.utils.std_comparisons import std_equal_with_precision


class RCTPrecision(TypedDict):
precision: float
unit: str | None


class RuleDefinitionBase:
Expand All @@ -14,17 +24,18 @@ def __init__(
self,
rmds_used,
rmds_used_optional=None,
id=None,
description=None,
ruleset_section_title=None,
standard_section=None,
is_primary_rule=None,
rmd_context="",
id: str = None,
description: str = None,
ruleset_section_title: str = None,
standard_section: str = None,
is_primary_rule: bool = None,
rmd_context: str = "",
required_fields=None,
manual_check_required_msg="",
fail_msg="",
pass_msg="",
not_applicable_msg="",
manual_check_required_msg: str = "",
fail_msg: str = "",
pass_msg: str = "",
not_applicable_msg: str = "",
precision: Mapping[str, RCTPrecision] = None,
):
"""Base class for all Rule definitions
Expand Down Expand Up @@ -67,6 +78,15 @@ def __init__(
default message for PASS outcome
not_applicable_msg: string
default message for NOT_APPLICABLE outcome
precision: dict
precision value(s) in a dictionary
e.g.,
{
"subsurface_u_factor_b": {
"precision": 0.01,
"unit": "Btu/(hr*ft2*R)"
}
}
"""
self.rmds_used = rmds_used
self.rmds_used_optional = rmds_used_optional
Expand All @@ -85,6 +105,22 @@ def __init__(
self.not_applicable_msg = not_applicable_msg
self.fail_msg = fail_msg
self.pass_msg = pass_msg
self.precision_comparison = None

if precision:
self.precision_comparison = {
# if no unit, handle it as a dimensionless value.
key: partial(
std_equal_with_precision,
precision=val["precision"] * ureg(val["unit"])
if val.get("unit")
else val["precision"],
)
for key, val in precision.items()
}
else:
# default comparison to be strict equality comparison
self.precision_comparison = lambda val, std_val: val == std_val

def evaluate(self, rmds, data={}):
"""Generates the outcome dictionary for the rule
Expand Down
4 changes: 3 additions & 1 deletion rct229/rule_engine/rule_list_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def __init__(
# An example data object:
# {"cliimate_zone": ("baseline", weather/climate_zone")}
data_items=None,
precision=None,
):
self.each_rule = each_rule
self.data_items = data_items
Expand All @@ -40,6 +41,7 @@ def __init__(
ruleset_section_title=ruleset_section_title,
standard_section=standard_section,
is_primary_rule=is_primary_rule,
precision=precision,
)

def create_context_list(self, context, data):
Expand Down Expand Up @@ -167,7 +169,7 @@ def rule_check(self, context, calc_vals=None, data={}):
if self.list_filter(context_item, data)
]

# Evalutate the subrule for each item in the context list
# Evaluate the subrule for each item in the context list
outcomes = []
for ubp in filtered_context_list:
item_outcome = self.each_rule.evaluate(ubp, data)
Expand Down
2 changes: 2 additions & 0 deletions rct229/rule_engine/rule_list_indexed_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def __init__(
manual_check_required_msg="Manual Check Required",
not_applicable_msg="Not Applicable",
data_items=None,
precision=None,
):
self.index_rmd = index_rmd
self.list_path = list_path
Expand All @@ -90,6 +91,7 @@ def __init__(
ruleset_section_title=ruleset_section_title,
standard_section=standard_section,
is_primary_rule=is_primary_rule,
precision=precision,
)

def create_context_list(self, context, data):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def aggregate_min_OA_schedule_across_zones(
)

if len(zone_OA_CFM_list_of_schedules) == 1:
# one schedule sceanrio
# one schedule scenario
hourly_zone_running_OA_CFM_total = zone_OA_CFM_list_of_schedules[0]
else:
# multi-schedule scenario
Expand Down
12 changes: 11 additions & 1 deletion rct229/rulesets/ashrae9012019/section18/section18rule1.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ def __init__(self):
rmds_used=produce_ruleset_model_description(
USER=False, BASELINE_0=True, PROPOSED=True
),
precision={
"building_total_lab_exhaust_p": {
"precision": 1,
"unit": "cfm",
},
},
)

def get_calc_vals(self, context, data=None):
Expand Down Expand Up @@ -169,7 +175,11 @@ def manual_check_required(self, context, calc_vals=None, data=None):
is_undetermined = False
if system_origin_b == SYSTEMORIGIN.G311D:
is_undetermined = (
building_total_lab_exhaust_p <= EXHAUST_AIRFLOW_15000
building_total_lab_exhaust_p < EXHAUST_AIRFLOW_15000
or self.precision_comparison["building_total_lab_exhaust_p"](
building_total_lab_exhaust_p,
EXHAUST_AIRFLOW_15000,
)
)
elif system_origin_b == SYSTEMORIGIN.G311E:
is_undetermined = is_zone_likely_a_vestibule_b[zone_id_b]
Expand Down
28 changes: 24 additions & 4 deletions rct229/rulesets/ashrae9012019/section19/section19rule1.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ def __init__(self):
rmds_used=produce_ruleset_model_description(
USER=False, BASELINE_0=True, PROPOSED=False
),
precision={
"heating_oversizing_factor": {
"precision": 0.01,
},
"cooling_oversizing_factor": {
"precision": 0.01,
},
},
)

def is_applicable(self, context, data=None):
Expand Down Expand Up @@ -153,18 +161,30 @@ def rule_check(self, context, calc_vals=None, data=None):

return (
(
REQ_HEATING_OVERSIZING_FACTOR == heating_oversizing_factor
and REQ_COOLING_OVERSIZING_FACTOR == cooling_oversizing_factor
self.precision_comparison["heating_oversizing_factor"](
heating_oversizing_factor,
REQ_HEATING_OVERSIZING_FACTOR,
)
and self.precision_comparison["cooling_oversizing_factor"](
cooling_oversizing_factor,
REQ_COOLING_OVERSIZING_FACTOR,
)
and heating_is_sized_based_on_design_day
and cooling_is_sized_based_on_design_day
)
or (
REQ_HEATING_OVERSIZING_FACTOR == heating_oversizing_factor
self.precision_comparison["heating_oversizing_factor"](
heating_oversizing_factor,
REQ_HEATING_OVERSIZING_FACTOR,
)
and heating_is_sized_based_on_design_day
and not cooling_oversizing_applicable
)
or (
REQ_COOLING_OVERSIZING_FACTOR == cooling_oversizing_factor
self.precision_comparison["cooling_oversizing_factor"](
cooling_oversizing_factor,
REQ_COOLING_OVERSIZING_FACTOR,
)
and cooling_is_sized_based_on_design_day
and not heating_oversizing_applicable
)
Expand Down
19 changes: 19 additions & 0 deletions rct229/rulesets/ashrae9012019/section19/section19rule12.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ def __init__(self):
required_fields={
"$": ["fan_system"],
},
precision={
"high_limit_temp_b": {
"precision": 0.1,
"unit": "K",
},
},
)

def is_applicable(self, context, data=None):
Expand Down Expand Up @@ -103,6 +109,19 @@ def rule_check(self, context, calc_vals=None, data=None):
high_limit_temp_b = calc_vals["high_limit_temp_b"]
air_economizer_type_b = calc_vals["air_economizer_type_b"]

return (
self.precision_comparison["high_limit_temp_b"](
high_limit_temp_b.to(ureg.kelvin),
req_high_limit_temp.to(ureg.kelvin),
)
and air_economizer_type_b == AIR_ECONOMIZER.TEMPERATURE
)

def is_tolerance_fail(self, context, calc_vals=None, data=None):
req_high_limit_temp = calc_vals["req_high_limit_temp"]
high_limit_temp_b = calc_vals["high_limit_temp_b"]
air_economizer_type_b = calc_vals["air_economizer_type_b"]

return (
std_equal(
req_high_limit_temp.to(ureg.kelvin),
Expand Down
72 changes: 62 additions & 10 deletions rct229/rulesets/ashrae9012019/section19/section19rule13.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from rct229.schema.config import ureg
from rct229.schema.schema_enums import SchemaEnums
from rct229.utils.assertions import getattr_
from rct229.utils.compare_standard_val import std_le
from rct229.utils.jsonpath_utils import find_all, find_one
from rct229.utils.pint_utils import ZERO, CalcQ
from rct229.utils.std_comparisons import std_equal
Expand Down Expand Up @@ -64,6 +65,16 @@ def __init__(self):
is_primary_rule=True,
rmd_context="ruleset_model_descriptions/0",
list_path="$.buildings[*].building_segments[*].heating_ventilating_air_conditioning_systems[*]",
precision={
"delta_supply_and_design_heating_temp": {
"precision": 1,
"unit": "delta_degF",
},
"delta_supply_and_design_cooling_temp": {
"precision": 1,
"unit": "delta_degF",
},
},
)

def is_applicable(self, context, data=None):
Expand Down Expand Up @@ -153,13 +164,17 @@ def create_data(self, context, data):
"all_design_setpoints_delta_Ts_are_per_reqs"
] = all(
[
std_equal(
LABORATORY_TEMP_DELTA,
self.precision_comparison[
"delta_supply_and_design_heating_temp"
](
delta_supply_and_design_heating_temp,
),
std_equal(
LABORATORY_TEMP_DELTA,
),
self.precision_comparison[
"delta_supply_and_design_cooling_temp"
](
delta_supply_and_design_cooling_temp,
LABORATORY_TEMP_DELTA,
),
]
)
Expand All @@ -168,13 +183,17 @@ def create_data(self, context, data):
"all_design_setpoints_delta_Ts_are_per_reqs"
] = all(
[
std_equal(
GENERAL_TEMP_DELTA,
self.precision_comparison[
"delta_supply_and_design_heating_temp"
](
delta_supply_and_design_heating_temp,
),
std_equal(
GENERAL_TEMP_DELTA,
),
self.precision_comparison[
"delta_supply_and_design_cooling_temp"
](
delta_supply_and_design_cooling_temp,
GENERAL_TEMP_DELTA,
),
]
)
Expand Down Expand Up @@ -210,6 +229,12 @@ def __init__(self):
"$": ["fan_system"],
"fan_system": ["minimum_outdoor_airflow"],
},
precision={
"supply_fans_airflow_b": {
"precision": 1,
"unit": "cfm",
},
},
)

def get_calc_vals(self, context, data=None):
Expand Down Expand Up @@ -249,8 +274,12 @@ def manual_check_required(self, context, calc_vals=None, data=None):
"all_design_setpoints_delta_Ts_are_per_reqs_b"
]

return not all_design_setpoints_delta_Ts_are_per_reqs_b and std_equal(
zone_info["supply_flow_p"], supply_fans_airflow_b
return (
not all_design_setpoints_delta_Ts_are_per_reqs_b
and self.precision_comparison["supply_fans_airflow_b"](
supply_fans_airflow_b,
zone_info["supply_flow_p"],
)
)

def get_manual_check_required_msg(self, context, calc_vals=None, data=None):
Expand All @@ -274,6 +303,29 @@ def rule_check(self, context, calc_vals=None, data=None):
all_design_setpoints_delta_Ts_are_per_reqs_b
and are_all_hvac_sys_fan_objs_autosized_b
and supply_fans_airflow_b >= fan_minimum_outdoor_airflow_b
) or (
(
not all_design_setpoints_delta_Ts_are_per_reqs_b
and fan_minimum_outdoor_airflow_b == supply_fans_airflow_b
)
)

def is_tolerance_fail(self, context, calc_vals=None, data=None):
all_design_setpoints_delta_Ts_are_per_reqs_b = calc_vals[
"all_design_setpoints_delta_Ts_are_per_reqs_b"
]
are_all_hvac_sys_fan_objs_autosized_b = calc_vals[
"are_all_hvac_sys_fan_objs_autosized_b"
]
supply_fans_airflow_b = calc_vals["supply_fans_airflow_b"]
fan_minimum_outdoor_airflow_b = calc_vals["fan_minimum_outdoor_airflow_b"]

return (
all_design_setpoints_delta_Ts_are_per_reqs_b
and are_all_hvac_sys_fan_objs_autosized_b
and std_le(
val=supply_fans_airflow_b, std_val=fan_minimum_outdoor_airflow_b
)
) or (
(
not all_design_setpoints_delta_Ts_are_per_reqs_b
Expand Down
Loading
Loading