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

DHW-related verification items development #46

Merged
4 changes: 4 additions & 0 deletions constrain/library/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
from .G36ReheatTerminalBoxHeatingAirflowSetpoint import *
from .G36ReheatTerminalBoxDeadbandAirflowSetpoint import *
from .G36TerminalBoxCoolingMinimumAirflow import *
from .hpwh_sizing import *
from .dhw_tank_temperature import *

__all__ = [
"AutomaticOADamperControl",
Expand Down Expand Up @@ -110,4 +112,6 @@
"G36ReheatTerminalBoxHeatingAirflowSetpoint",
"G36ReheatTerminalBoxDeadbandAirflowSetpoint",
"G36TerminalBoxCoolingMinimumAirflow",
"HPWH_sizing",
"DHW_tank_temperature",
]
23 changes: 23 additions & 0 deletions constrain/library/dhw_tank_temperature.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from constrain.checklib import RuleCheckBase


class DHW_tank_temperature(RuleCheckBase):
yunjoonjung-PNNL marked this conversation as resolved.
Show resolved Hide resolved
points = ["T_dhw", "T_dhw_deadband", "T_dhw_design_parameter"]

def check_dhw_temperature(self, data):
if (
abs(data["T_dhw"] - data["T_dhw_design_parameter"])
<= 0.5 * data["T_dhw_deadband"]
):
return True
else:
return False

def verify(self):
self.result = self.df.apply(lambda d: self.check_dhw_temperature(d), axis=1)

def check_bool(self):
if len(self.result[self.result == False] > 0):
return False
else:
return True
52 changes: 52 additions & 0 deletions constrain/library/hpwh_sizing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from constrain.checklib import RuleCheckBase
import numpy as np

PERCENT_TOLERANCE = 0.01 # %
lymereJ marked this conversation as resolved.
Show resolved Hide resolved


class HPWH_sizing(RuleCheckBase):
points = [
"T_amb",
"HeatingRate_dx_coil",
"HeatingRate_waterheater1",
"HeatingRate_waterheater2",
"T_amb_parameter",
"HPWH_output_target_percent",
]

def verify(self):
self.df["total_hpwh_load"] = (
self.df["HeatingRate_dx_coil"]
+ self.df["HeatingRate_waterheater1"]
+ self.df["HeatingRate_waterheater2"]
)

self.df["HPWH_output"] = np.where(
self.df["total_hpwh_load"] != 0.0,
self.df["HeatingRate_dx_coil"] / self.df["total_hpwh_load"],
0.0,
)

min_hpwh_output = self.df[
(self.df["T_amb"] > self.df["T_amb_parameter"])
& (self.df["HPWH_output"] > 0.0)
]["HPWH_output"].min()
min_hpwh_output = 0.0 if min_hpwh_output is np.nan else min_hpwh_output

HPWH_output_target_percent = self.df["HPWH_output_target_percent"].iloc[0]

print(f"min_hpwh_output: {min_hpwh_output}")

self.df["result"] = (
True
if abs(min_hpwh_output - HPWH_output_target_percent) <= PERCENT_TOLERANCE
else False
)

self.result = self.df["result"]

def check_bool(self):
if len(self.result[self.result == False] > 0):
return False
else:
return True
8,761 changes: 8,761 additions & 0 deletions demo/hpwh_demo/IECC-state-current-5B_ApartmentMidRise_STD2021_WA-Spokane-WA.csv
Copy link
Collaborator Author

@yunjoonjung-PNNL yunjoonjung-PNNL Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lymereJ
I'll delete all the files in the demo/hpwh_demo, if these shouldn't be included. I included these for your review purpose.

Large diffs are not rendered by default.

71 changes: 71 additions & 0 deletions demo/hpwh_demo/hpwh_demo_verification_cases.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"cases": [
{
"no": 1,
"run_simulation": false,
"simulation_IO": {
"idf": "./test_cases/doe_prototype_cases/ASHRAE901_Hospital_STD2019_Atlanta.idf",
"idd": "./resources/Energy+V9_0_1.idd",
"weather": "./weather/USA_GA_Atlanta-Hartsfield.Jackson.Intl.AP.722190_TMY3.epw",
"output": "../resources/IECC-state-current-5B_ApartmentMidRise_STD2021_WA-Spokane-WA.csv",
"ep_path": "C:\\EnergyPlusV9-0-1\\energyplus.exe"
},
"expected_result": "pass",
"datapoints_source": {
"idf_output_variables": {
"T_amb": {
"subject": "Environment",
"variable": "Site Outdoor Air Drybulb Temperature",
"frequency": "TimeStep"
},
"HeatingRate_dx_coil": {
"subject": "SWHSYS1 HPWH DXCOIL",
"variable": "Cooling Coil Total Water Heating Rate",
"frequency": "TimeStep"
},
"HeatingRate_waterheater1": {
"subject": "SWHSYS1 HPWH TANK",
"variable": "Water Heater Heater 1 Heating Rate",
"frequency": "TimeStep"
},
"HeatingRate_waterheater2": {
"subject": "SWHSYS1 HPWH TANK",
"variable": "Water Heater Heater 2 Heating Rate",
"frequency": "TimeStep"
}
},
"parameters": {
"T_amb_parameter": 3.7,
"HPWH_output_target_percent": 0.55
}
},
"verification_class": "HPWH_sizing"
},
{
"no": 2,
"run_simulation": false,
"simulation_IO": {
"idf": "./test_cases/doe_prototype_cases/ASHRAE901_Hospital_STD2019_Atlanta.idf",
"idd": "./resources/Energy+V9_0_1.idd",
"weather": "./weather/USA_GA_Atlanta-Hartsfield.Jackson.Intl.AP.722190_TMY3.epw",
"output": "../resources/IECC-state-current-5B_ApartmentMidRise_STD2021_WA-Spokane-WA.csv",
"ep_path": "C:\\EnergyPlusV9-0-1\\energyplus.exe"
},
"expected_result": "pass",
"datapoints_source": {
"idf_output_variables": {
"T_dhw": {
"subject": "SWHSYS1 HPWH TANK",
"variable": "Water Heater Use Side Outlet Temperature",
"frequency": "TimeStep"
}
},
"parameters": {
"T_dhw_deadband": 5.0,
"T_dhw_design_parameter": 60
}
},
"verification_class": "DHW_tank_temperature"
}
]
}
94 changes: 94 additions & 0 deletions demo/hpwh_demo/hpwh_demo_workflow.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"workflow_name": "HPWH workflow",
"meta": {
"author": "Yun Joon Jung",
"date": "08/26/2024",
"version": "1.0",
"description": "Demo workflow to showcase core Workflow API functionalities"
},
"imports": [
"numpy as np",
"pandas as pd",
"glob"
],
"states": {
"load timeseries data": {
"Type": "MethodCall",
"MethodCall": "DataProcessing",
"Parameters": {
"data_path": "./demo/hpwh_demo/IECC-state-current-5B_ApartmentMidRise_STD2021_WA-Spokane-WA.csv",
"data_source": "EnergyPlus"
},
"Payloads": {"data_processing_obj": "$", "data": "$.data"},
"Start": "True",
"Next": "load original verification case"
},
"load original verification case": {
"Type": "MethodCall",
"MethodCall": "VerificationCase",
"Parameters": {
"json_case_path": "./demo/hpwh_demo/hpwh_demo_verification_cases.json"
},
"Payloads": {
"verification_case_obj": "$",
"original_case_keys": "$.case_suite.keys()"
},
"Next": "setup verification"
},
"setup verification": {
"Type": "MethodCall",
"MethodCall": "Verification",
"Parameters": {"verifications": "Payloads['verification_case_obj']"},
"Payloads": {"verification_obj": "$"},
"Next": "configure verification runner"
},
"configure verification runner": {
"Type": "MethodCall",
"MethodCall": "Payloads['verification_obj'].configure",
"Parameters": {
"output_path": "./demo/hpwh_demo/outputs",
"lib_items_path": "./schema/library.json",
"plot_option": "+x None",
"fig_size": "+x (6, 5)",
"num_threads": 1,
"preprocessed_data": "Payloads['data']"
},
"Payloads": {},
"Next": "run verification"
},
"run verification": {
"Type": "MethodCall",
"MethodCall": "Payloads['verification_obj'].run",
"Parameters": {},
"Payloads": {"verification_return": "$"},
"Next": "reporting_object_instantiation"
},
"reporting_object_instantiation": {
"Type": "MethodCall",
"MethodCall": "Reporting",
"Parameters": {
"verification_json": "./demo/hpwh_demo/outputs/*_md.json",
"result_md_name": "report_summary.md",
"report_format": "markdown"
},
"Payloads": {"reporting_obj": "$"},
"Next": "report cases"
},
"report cases": {
"Type": "MethodCall",
"MethodCall": "Payloads['reporting_obj'].report_multiple_cases",
"Parameters": {},
"Payloads": {},
"Next": "Success"
},
"Success": {
"Type": "MethodCall",
"MethodCall": "print",
"Parameters": [
"Congratulations! the demo workflow is executed with expected results and no error!"
],
"Payloads": {},
"End": "True"
}
}
}
10 changes: 10 additions & 0 deletions demo/hpwh_demo/hpwh_demo_workflow_runner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import sys
import warnings

sys.path.append("./constrain")
from api import Workflow

warnings.simplefilter(action="ignore", category=FutureWarning)
warnings.simplefilter(action="ignore", category=ResourceWarning)
workflow = Workflow(workflow="./demo/hpwh_demo/hpwh_demo_workflow.json")
workflow.run_workflow(verbose=True)
48 changes: 48 additions & 0 deletions schema/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -1556,5 +1556,53 @@
" pass",
"end"
]
},
"HPWH_sizing": {
"library_item_id": 68,
"description_brief": "The algorithm verifies whether hpwh DX coil can achieve 100% heating rate at every time step.",
"description_index": [
"N/A"
],
"description_datapoints": {
"T_amb": "outdoor ambient temperature",
"HeatingRate_dx_coil": "HPWH coil's total water heating rate",
"HeatingRate_waterheater1": "HPWH 1 heating rate",
"HeatingRate_waterheater2": "HPWH 2 heating rate",
"T_amb_parameter": "outdoor ambient temperature parameter",
"HPWH_output_target_percent": "HPWH output target in percent"
},
"description_verification_type": "rule-based",
"assertions_type": "pass",
"description_assertions": [
"total_hpwh_load = HeatingRate_dx_coil + HeatingRate_waterheater1 + HeatingRate_waterheater2",
"HPWH_output = np.where(df['total_hpwh_load'] != 0.0, df['HeatingRate_dx_coil'] / df['total_hpwh_load'] * 100, 0.0)",
"min_hpwh_output = df[(df['T_amb'] > df['T_amb_parameter']) & (df['HPWH_output'] > 0.0)]['HPWH_output'].min()",
"if abs(min_hpwh_output - HPWH_output_target_percent) <= tolerance: ",
" pass",
"else: ",
" fail",
"end"
]
},
"DHW_tank_temperature": {
"library_item_id": 69,
"description_brief": "The algorithm verifies whether water temperature in the domestic hot water tank is within the deadband.",
"description_index": [
"N/A"
],
"description_datapoints": {
"T_dhw": "Water temperature in DHW tank",
"T_dhw_deadband": "DHW tank temperature deadband",
"T_dhw_design_parameter": "DHW tank design temperature"
},
"description_verification_type": "rule-based",
"assertions_type": "pass",
"description_assertions": [
"if abs(T_dhw - T_dhw_design_parameter) <= 0.5 * T_dhw_deadband:",
" pass",
"else: ",
" fail",
"end"
]
}
}
Loading
Loading