Skip to content

Commit

Permalink
fix minor problems
Browse files Browse the repository at this point in the history
  • Loading branch information
Wan, Hanlong committed Oct 14, 2024
1 parent 613ee0d commit 6669e7f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
34 changes: 17 additions & 17 deletions copper/unitarydirectexpansion.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __init__(
"4": 0.63 * 0.9437,
},
indoor_fan_speeds=1,
indoor_fan_curve=None,
indoor_fan_curve=False,
indoor_fan_power_unit="kW",
):
global log_fan
Expand Down Expand Up @@ -247,47 +247,47 @@ def add_cycling_degradation_curve(self, overwrite=False, return_curve=False):
self.default_fan_curve.coeff3 = self.indoor_fan_curve_coef["3"]
self.default_fan_curve.coeff4 = self.indoor_fan_curve_coef["4"]

def calc_fan_power(self, capacity_ratio):
def calc_fan_power(self, capacity_fraction):
"""Calculate unitary DX equipment fan power.
:param float capacity_ratio: Ratio of actual capacity to net rated capacity
:param float capacity_fraction: Ratio of actual capacity to net rated capacity
:return: Unitary DX Equipment fan power in Watts
:rtype: float
"""
# Full flow/power
flow_fraction = (
capacity_ratio # we assume flow_fraction = 1*capacity_ratio as default
capacity_fraction # we assume flow_fraction = 1*capacity_fraction as default
)
if capacity_ratio == 1 or self.indoor_fan_speeds == 1:
if capacity_fraction == 1 or self.indoor_fan_speeds == 1:
return self.indoor_fan_power
else:
if self.indoor_fan_curve == None:
capacity_ratios = []
if self.indoor_fan_curve == False:
capacity_fractions = []
fan_power_fractions = []
for speed_info in self.indoor_fan_speeds_mapping.values():
capacity_ratios.append(speed_info["capacity_fraction"])
capacity_fractions.append(speed_info["capacity_fraction"])
fan_power_fractions.append(speed_info["fan_power_fraction"])
# Minimum flow/power
if capacity_ratio <= capacity_ratios[0]:
if capacity_fraction <= capacity_fractions[0]:
return self.indoor_fan_power * fan_power_fractions[0]
elif capacity_ratio in capacity_ratios:
elif capacity_fraction in capacity_fractions:
return (
self.indoor_fan_power
* fan_power_fractions[capacity_ratios.index(capacity_ratio)]
* fan_power_fractions[capacity_fractions.index(capacity_fraction)]
)
else:
# In between-speeds: determine power by linear interpolation
for i, ratio in enumerate(capacity_ratios):
for i, ratio in enumerate(capacity_fractions):
if (
ratio < capacity_ratio
and capacity_ratios[i + 1] > capacity_ratio
ratio < capacity_fraction
and capacity_fractions[i + 1] > capacity_fraction
):
a = (
fan_power_fractions[i + 1] - fan_power_fractions[i]
) / (capacity_ratios[i + 1] - capacity_ratios[i])
b = fan_power_fractions[i] - a * capacity_ratios[i]
return self.indoor_fan_power * (a * capacity_ratio + b)
) / (capacity_fractions[i + 1] - capacity_fractions[i])
b = fan_power_fractions[i] - a * capacity_fractions[i]
return self.indoor_fan_power * (a * capacity_fraction + b)
else: # using curve
default_min_fan_power = (
self.indoor_fan_power * 0.25
Expand Down
24 changes: 12 additions & 12 deletions tests/test_unitarydirectexpansion.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,17 @@ def test_multi_speed(self):
dx_unit_two_speed = self.dx_unit_dft
dx_unit_two_speed.indoor_fan_speeds = 2
assert (
dx_unit_two_speed.calc_fan_power(capacity_ratio=0.5)
dx_unit_two_speed.calc_fan_power(capacity_fraction=0.5)
/ dx_unit_two_speed.indoor_fan_power
== 0.4
)
assert (
dx_unit_two_speed.calc_fan_power(capacity_ratio=1.0)
dx_unit_two_speed.calc_fan_power(capacity_fraction=1.0)
/ dx_unit_two_speed.indoor_fan_power
== 1.0
)
assert (
dx_unit_two_speed.calc_fan_power(capacity_ratio=0.75)
dx_unit_two_speed.calc_fan_power(capacity_fraction=0.75)
/ dx_unit_two_speed.indoor_fan_power
== 0.7
)
Expand Down Expand Up @@ -149,31 +149,31 @@ def test_multi_speed(self):
},
}
assert (
dx_unit_four_speed.calc_fan_power(capacity_ratio=0.1)
dx_unit_four_speed.calc_fan_power(capacity_fraction=0.1)
/ dx_unit_four_speed.indoor_fan_power
== 0.15
)
assert (
dx_unit_four_speed.calc_fan_power(capacity_ratio=1.0)
dx_unit_four_speed.calc_fan_power(capacity_fraction=1.0)
/ dx_unit_four_speed.indoor_fan_power
== 1.0
)
assert (
dx_unit_four_speed.calc_fan_power(capacity_ratio=0.75)
dx_unit_four_speed.calc_fan_power(capacity_fraction=0.75)
/ dx_unit_four_speed.indoor_fan_power
== 0.7
)
assert (
round(
dx_unit_four_speed.calc_fan_power(capacity_ratio=0.58)
dx_unit_four_speed.calc_fan_power(capacity_fraction=0.58)
/ dx_unit_four_speed.indoor_fan_power,
2,
)
== 0.53
)
assert (
round(
dx_unit_four_speed.calc_fan_power(capacity_ratio=0.70)
dx_unit_four_speed.calc_fan_power(capacity_fraction=0.70)
/ dx_unit_four_speed.indoor_fan_power,
2,
)
Expand All @@ -183,20 +183,20 @@ def test_multi_speed(self):
def test_multi_speed_with_curve(self):
# Two-speed fan unit
dx_unit_multi_speed = self.dx_unit_dft
dx_unit_multi_speed.indoor_fan_curve = 1
dx_unit_multi_speed.indoor_fan_curve = True
dx_unit_multi_speed.indoor_fan_speeds = 2
assert (
dx_unit_multi_speed.calc_fan_power(capacity_ratio=0.5)
dx_unit_multi_speed.calc_fan_power(capacity_fraction=0.5)
/ dx_unit_multi_speed.indoor_fan_power
== 0.25
)
assert (
dx_unit_multi_speed.calc_fan_power(capacity_ratio=1.0)
dx_unit_multi_speed.calc_fan_power(capacity_fraction=1.0)
/ dx_unit_multi_speed.indoor_fan_power
== 1.0
)
assert (
dx_unit_multi_speed.calc_fan_power(capacity_ratio=0.75)
dx_unit_multi_speed.calc_fan_power(capacity_fraction=0.75)
/ dx_unit_multi_speed.indoor_fan_power
< 0.7
)
Expand Down

0 comments on commit 6669e7f

Please sign in to comment.