Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ Removed. `scripts/bump_version.py` turns them into a release section.

### Changed

- I-P conversions use one exact BTU factor (1 W = 3.41214 BTU/h, 1 TR = 3516.85 W) instead of a
mix of 3.412 and 1/0.293, so I-P values shown and entered (BTU, BTU/h, kBTU, TR, lb CO₂e/kBTU)
shift by up to 0.03 %; results in SI are unchanged (#227)
- Performance curve plots restyled: white background with light grid, legend above the plot,
outdoor air temperature labelled under both AWHP panels, unified hover, the part of a curve outside its operating limits drawn dashed, and the original
curves shown in grey behind a custom copy (#171)
Expand Down Expand Up @@ -86,6 +89,9 @@ Removed. `scripts/bump_version.py` turns them into a release section.

### Fixed

- Heat rejection/recovery capacities entered in BTU/h in the Edit Equipment Scenario modal were
stored slightly off (100000 showed as 100028.4) because saving and display used different
BTU/h factors (#227)
- Combined LRMER/SRMER/AER CO₂e rate columns in the results CSV were not converted (and had no
unit) in IP mode
- Applying load scaling repeatedly no longer compounds the scale factor
Expand Down
4 changes: 2 additions & 2 deletions notes/unit-conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,11 @@ UNIT_MAP = {
AUTO_SCALE_CONFIG = {
"energy": {
"SI": [(1e9, "GWh"), (1e6, "MWh"), (1e3, "kWh")],
"IP": [(1e3/3.412, "kBTU")],
"IP": [(1e3 * BTU_to_Wh, "kBTU")],
},
"power": {
"SI": [(1e6, "MW"), (1e3, "kW")],
"IP": [(1e3/3.412, "kBTU/h")],
"IP": [(1e3 * BTUh_to_W, "kBTU/h")],
},
"power_cooling": {
"SI": [(1e6, "MW"), (1e3, "kW")],
Expand Down
18 changes: 6 additions & 12 deletions pages/equipment_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -1041,9 +1041,12 @@ def save_edit_scenario(
if not new_name:
return True, no_update, "Scenario name cannot be empty."

from utils.units import BTUh_to_Wh, F_to_C, kWh_to_Wh
from utils.units import F_to_C, get_inverse_converter

unit_mode = unit_mode or "SI"
# exact inverse of the power converter open_edit_modal displays with (kW or BTU/h -> W),
# so a saved value reopens unchanged (#227)
power_to_base = get_inverse_converter("power", unit_mode)

if hr_wwhp_val == "None":
hr_wwhp_val = None
Expand Down Expand Up @@ -1079,22 +1082,13 @@ def save_edit_scenario(

if hr_eac_rejection_cap_W_val is not None:
try:
hr_eac_rejection_cap_W_val = float(hr_eac_rejection_cap_W_val)
if unit_mode == "IP":
hr_eac_rejection_cap_W_val = BTUh_to_Wh(hr_eac_rejection_cap_W_val)
else:
# convert back to base W, because SI unit for power is kW not W
hr_eac_rejection_cap_W_val = kWh_to_Wh(hr_eac_rejection_cap_W_val)
hr_eac_rejection_cap_W_val = power_to_base(float(hr_eac_rejection_cap_W_val))
except (ValueError, TypeError):
hr_eac_rejection_cap_W_val = None

if hr_eac_recovery_cap_W_val is not None:
try:
hr_eac_recovery_cap_W_val = float(hr_eac_recovery_cap_W_val)
if unit_mode == "IP":
hr_eac_recovery_cap_W_val = BTUh_to_Wh(hr_eac_recovery_cap_W_val)
else:
hr_eac_recovery_cap_W_val = kWh_to_Wh(hr_eac_recovery_cap_W_val)
hr_eac_recovery_cap_W_val = power_to_base(float(hr_eac_recovery_cap_W_val))
except (ValueError, TypeError):
hr_eac_recovery_cap_W_val = None

Expand Down
4 changes: 2 additions & 2 deletions pages/loads_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ def update_table(

if hhw_range and len(hhw_range) == 2:
if unit_mode == "IP":
# kBTU/h → W (1 kBTU/h = 1e3 BTU/h = 1e3/3.412 W)
# kBTU/h → W (1 kBTU/h = 1e3 BTU/h = 1e3 * BTUh_to_W W)
w_per_kbtu = 1e3 / W_to_BTUh
hhw_range = [h * w_per_kbtu for h in hhw_range]
else:
Expand Down Expand Up @@ -1333,7 +1333,7 @@ def update_slider_units(unit_mode):
area_max = int(sqm_to_sqft(area_max_si))
area_step = 5000

# Convert HHW: W → kBTU/h (1 kBTU/h = 1e3 BTU/h = 1e3/3.412 W)
# Convert HHW: W → kBTU/h (1 kBTU/h = 1e3 BTU/h = 1e3 * BTUh_to_W W)
# Using kBTU/h to avoid excessively large numbers
kbtu_per_w = W_to_BTUh / 1e3 # W to kBTU/h
hhw_min = round(hhw_min_si * kbtu_per_w, 1)
Expand Down
32 changes: 16 additions & 16 deletions utils/units.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# any constants used in the analysis
# unit conversions
# all are multiplied, right to left
ton_to_W = 12000 * 0.293 # refrigerant-ton to W
BTUh_to_W = (
1055.05585262 / 3600
) # BTU/hr to W (IT BTU, ≈ 0.29307); every BTU factor derives from this
W_to_BTUh = 1 / BTUh_to_W # ≈ 3.41214
BTU_to_Wh = BTUh_to_W # same factor: BTU to Wh is BTU/h to W
Wh_to_BTU = W_to_BTUh
ton_to_W = 12000 * BTUh_to_W # refrigerant-ton to W (≈ 3516.85)
W_to_ton = 1 / ton_to_W
BTUh_to_W = 0.293 # BTU/hr to W
W_to_BTUh = 1 / BTUh_to_W
Wh_to_BTU = 3.412
BTU_to_Wh = 1 / Wh_to_BTU
lbs_to_ton = 0.454 / 1000 # lbs (e.g. of CO2) to metric tons
ton_to_lbs = 1 / lbs_to_ton
lb_to_kg = 0.454 # lbs (e.g. of CO2) to metric tons
Expand Down Expand Up @@ -45,11 +47,11 @@ def kWh_to_Wh(kWh):


def Wh_to_BTUh(Wh):
return Wh * 3.412
return Wh * Wh_to_BTU


def BTUh_to_Wh(BTUh):
return BTUh / 3.412
return BTUh * BTU_to_Wh


def kg_to_lbs(kg):
Expand Down Expand Up @@ -387,11 +389,10 @@ def sqft_to_sqm(sqft):
(1e3, 1e3, "kWh"), # >= 1 kWh (in Wh) → kWh
],
"IP": [
# 1 Wh = 3.412 BTU; kBTU = 1e3 BTU
# Threshold: 1 kBTU = 1e3 BTU = 1e3/3.412 Wh ≈ 293.083 Wh
# Scale: divide Wh by (1e3/3.412) to get kBTU
# (1e3 / 3.412, 1e3 / 3.412, "kBTU"),
(1e3 / 3.412, 1e3 / 3.412, "kBTU"),
# kBTU = 1e3 BTU
# Threshold: 1 kBTU = 1e3 * BTU_to_Wh ≈ 293.07 Wh
# Scale: divide Wh by (1e3 * BTU_to_Wh) to get kBTU
(1e3 * BTU_to_Wh, 1e3 * BTU_to_Wh, "kBTU"),
],
},
"energy_electric": {
Expand All @@ -414,10 +415,9 @@ def sqft_to_sqm(sqft):
(1e3, 1e3, "kW"), # >= 1 kW (in W) → kW
],
"IP": [
# 1 W = 3.412 BTU/h; kBTU/h = 1e3 BTU/h
# Threshold: 1 kBTU/h = 1e3/3.412 W ≈ 293.083 W
# (1e3 / 3.412, 1e3 / 3.412, "kBTU/h"),
(1e3 / 3.412, 1e3 / 3.412, "kBTU/h"),
# kBTU/h = 1e3 BTU/h
# Threshold: 1 kBTU/h = 1e3 * BTUh_to_W ≈ 293.07 W
(1e3 * BTUh_to_W, 1e3 * BTUh_to_W, "kBTU/h"),
],
},
"power_cooling": {
Expand Down
Loading