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
34 changes: 34 additions & 0 deletions constrain/library/hpwh_sizing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from constrain.checklib import RuleCheckBase


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

def hpwh_load(self, data):
total_hpwh_load = (
data["HeatingRate_dx_coil"]
+ data["HeatingRate_waterheater1"]
+ data["HeatingRate_waterheater2"]
)

if data["T_amb"] <= data["T_amb_parameter"] or total_hpwh_load == 0.0:
return "untested"
elif data["HeatingRate_dx_coil"] / total_hpwh_load >= 1:
return True
yunjoonjung-PNNL marked this conversation as resolved.
Show resolved Hide resolved
else:
return False

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

def check_bool(self):
if len(self.result[self.result == False] > 0):
return False
else:
return True
96 changes: 96 additions & 0 deletions design/dhw_tank_temperature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Control Verification Algorithm -- DHW_tank_temperature
Copy link
Collaborator Author

@yunjoonjung-PNNL yunjoonjung-PNNL Aug 23, 2024

Choose a reason for hiding this comment

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

@lymereJ
I added these markdown documents for your review. I plan to delete these after review.


Author: _Yun Joon Jung, Jeremy Lerond_
Updated: _08/22/2024_

<!--
- Recommend formatting markdown with prettier https://prettier.io/ (available as vscode extension)
- `---` are added for easy presentation later (with things like slidev https://sli.dev/ )
-->

---

## Verification Name

_DHW_tank_temperature_

## Verification Description

_TBD_

## Code Requirements

### Code requirement

**Code Name:** _NA_
**Code Year:** _NA_
**Code Section:** _NA_
**Code Subsection:** _NA_

---

## Verification Approaches

### Verification Approach

_We aim to verify this control verification item by examing water temperature in the domestic hot water tank._

---

#### Verification Type

_rule-based_

#### Verification Applicability

- **Building Type(s):** _any_
- **Space Type(s):** _any_
- **System(s):**
_1. domestic hot water system._
- **Climate Zone(s):** _any_
- **Component(s):**

---

#### Verification Algorithm Data Points
- _T_dhw_
- Data Value Unit: _deg C_
- Data point Description: _Water Heater Temperature_
- Data Point Affiliation: _Domestic Hot Water System_

- _T_dhw_deadband_
- Data Value Unit: _deg C_
- Data point Description: _Water Heater Temperature Temperature Deadband_
- Data Point Affiliation: _Domestic Hot Water System_

- _T_dhw_design_parameter_
- Data Value Unit: _deg C_
- Data point Description: _Water Heater Temperature Parameter_
- Data Point Affiliation: _Domestic Hot Water System_

#### Verification Algorithm Description

_The algorithm verifies whether water temperature in the domestic hot water tank is within the deadband._

#### Verification Algorithm Pseudo Code

```
If abs(T_dhw_outlet - T_design_water_outlet_parameter) <= 0.5 * T_dhw_outlet_deadband
pass
else
fail
```

---

## Unit Tests

- _Provide a synthetic dataset that allow us to test both outcomes shown above: false and true._

---

## Implementation Description

_WIP_

#### Annotations
112 changes: 112 additions & 0 deletions design/hpwh_sizing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Control Verification Algorithm -- HPWH_sizing

Author: _Yun Joon Jung, Jeremy Lerond_
Updated: _08/22/2024_

<!--
- Recommend formatting markdown with prettier https://prettier.io/ (available as vscode extension)
- `---` are added for easy presentation later (with things like slidev https://sli.dev/ )
-->

---

## Verification Name

_HPWH_sizing_

## Verification Description

_TBD_

## Code Requirements

### Code requirement

**Code Name:** _N/A_
**Code Year:** _N/A_
**Code Section:** _N/A_
**Code Subsection:** _N/A_

---

## Verification Approaches

### Verification Approach

_We aim to verify this control verification item with heating rate from hpwh coils._

---

#### Verification Type

_rule-based_

#### Verification Applicability

- **Building Type(s):** _any_
- **Space Type(s):** _any_
- **System(s):**
_1. Heat pump Water Heater system with a stratified tank._
- **Climate Zone(s):** _any_
- **Component(s):**

---

#### Verification Algorithm Data Points

- _T_amb_
- Data Value Unit: deg C
- Data point Description: _Environment:Site Outdoor Air Drybulb Temperature_
- Data Point Affiliation: _Outdoor environment_

- _HeatingRate_dx_coil_
- Data Value Unit: _W_
- Data point Description: _Coil Total Water Heating Rate_
- Data Point Affiliation: _heat pump water heater_

- _HeatingRate_waterheater1_
- Data Value Unit: _W_
- Data point Description: _Water Heater Heater 1 Heating Rate_
- Data Point Affiliation: _heat pump water heater_

- _HeatingRate_waterheater2_
- Data Value Unit: _W_
- Data point Description: _Water Heater Heater 2 Heating Rate_
- Data Point Affiliation: _heat pump water heater_

- _T_amb_parameter_
- Data Value Unit: deg C
- Data point Description: _Environment:Site Outdoor Air Drybulb Temperature parameter_
- Data Point Affiliation: _Outdoor environment_


#### Verification Algorithm Description

_The algorithm verifies whether hpwh DX coil can achieve 100% heating rate at every time step._

#### Verification Algorithm Pseudo Code

```
total_load = hpwh_load + HeatingRate_waterheater1 + HeatingRate_waterheater2

if T_amb < T_amb_parameter or total_load == 0:
untested
else if hpwh_load / total_load >= 1
pass
else
fail
```

---

## Unit Tests

- _Provide a synthetic dataset that allow us to test both outcomes shown above: false and true._

---

## Implementation Description

_WIP_

#### Annotations
47 changes: 47 additions & 0 deletions tests/test_HPWH_sizing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import sys
import unittest

sys.path.append("./constrain")
import pandas as pd
from lib_unit_test_runner import *


class TestHPWHSizing(unittest.TestCase):
def test_HPWH_sizing(self):
points = [
"T_amb",
"HeatingRate_dx_coil",
"HeatingRate_waterheater1",
"HeatingRate_waterheater2",
"T_amb_parameter",
]

data = [
[3.0, 0, 0, 0, 3.7], # untested - when T_amb <= T_amb_parameter,
[5, 0, 0, 0, 3.7], # untested - when total_hpwh_load == 0
[
5.0,
30,
0,
0,
3.7,
], # pass - when `HeatingRate_dx_coil` can meet all the load
[
5.0,
30,
0,
20,
3.7,
], # fail - when `HeatingRate_dx_coil` cannot meet all the load
]

df = pd.DataFrame(data, columns=points)

verification_obj = run_test_verification_with_data("HPWH_sizing", df)

results = pd.Series(list(verification_obj.result))
expected_results = pd.Series(["untested", "untested", True, False])
self.assertTrue(results.equals(expected_results))

binary_result = verification_obj.check_bool()
self.assertFalse(binary_result)
33 changes: 33 additions & 0 deletions tests/test_dhw_tank_temperature.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import sys
import unittest

sys.path.append("./constrain")
import pandas as pd
from lib_unit_test_runner import *


class TestDHWTankTemperature(unittest.TestCase):
def test_dhw_tank_temperature(self):
points = [
"T_dhw",
"T_dhw_deadband",
"T_dhw_design_parameter",
]

data = [
[50, 2.0, 49], # Pass - dhw tank temp is within the deadband range
[50, 2.0, 51], # Pass - dhw tank temp is within the deadband range
[50, 2.0, 47], # Fail - dhw tank temp is out of the deadband range
[50, 2.0, 53], # Fail - dhw tank temp is out of the deadband range
]

df = pd.DataFrame(data, columns=points)

verification_obj = run_test_verification_with_data("DHW_tank_temperature", df)

results = pd.Series(list(verification_obj.result))
expected_results = pd.Series([True, True, False, False])
self.assertTrue(results.equals(expected_results))

binary_result = verification_obj.check_bool()
self.assertFalse(binary_result)
Loading