Skip to content

Commit

Permalink
Hook-up generator and new unitary DX equipment class.
Browse files Browse the repository at this point in the history
  • Loading branch information
lymereJ committed Aug 28, 2024
1 parent 4a27b3c commit 2cba643
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 27 deletions.
10 changes: 5 additions & 5 deletions copper/data/equipment_references.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@
}
}
},
"UnitaryDirectExpansion": {
"unitarydirectexpansion": {
"ahri_340/360": {
"water": {
"aed": [80,67],
"aew": [67,57],
"aed": 80,
"aew": 67,
"ae_unit": "degF",
"ect": [85.0, 73.5, 62.0, 55.0],
"ect_unit": "degF",
"lct": 95,
"lct_unit": "degF"
},
"air": {
"aed": [80,67],
"aew": [67,57],
"aed": 80,
"aew": 67,
"ae_unit": "degF",
"ect": [95.0, 81.5, 68.0, 65.0],
"ect_unit": "degF",
Expand Down
29 changes: 28 additions & 1 deletion copper/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ def run_ga(self, curves, verbose=False):

while not self.is_target_met():
self.pop = self.generate_population(curves)
while gen <= self.max_gen and not self.is_target_met():
while not self.is_target_met():
if gen >= self.max_gen:
break
self.evolve_population(self.pop)
gen += 1
if verbose:
Expand Down Expand Up @@ -220,6 +222,11 @@ def run_ga(self, curves, verbose=False):
f"Target not met after {self.max_restart} restart; No solution was found."
)
return
else:
logging.critical(
f"Target not met after {self.max_gen} generations; No solution was found."
)
return

logging.info("Target met after {} generations.".format(gen))
return self.pop
Expand Down Expand Up @@ -259,6 +266,26 @@ def is_target_met(self):
cap_rating += abs(1 - c.get_out_reference(self.equipment))
else:
return False
elif self.equipment.type == "UnitaryDirectExpansion":
if self.equipment.set_of_curves != "":
part_rating = self.equipment.calc_rated_eff(
eff_type="ieer", unit=self.equipment.part_eff_unit
)
part_rating_alt = 0
full_rating_alt = 0
full_rating = self.full_eff
cap_rating = 0
# full_rating = self.equipment.calc_rated_eff(
# eff_type="full", unit=self.equipment.full_eff_unit
# )
# cap_rating = 0
# if "cap-f-t" in self.vars:
# for c in self.equipment.set_of_curves:
# # set_of_curves
# if "cap" in c.out_var:
# cap_rating += abs(1 - c.get_out_reference(self.equipment))
else:
return False
else:
raise ValueError("This type of equipment has not yet been implemented.")

Expand Down
44 changes: 23 additions & 21 deletions copper/unitarydirectexpansion.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,12 @@ def __init__(
self.fan_power = fan_power
self.full_eff = full_eff
self.full_eff_unit = full_eff_unit
self.full_eff_alt = 0
self.full_eff_alt_unit = full_eff_unit
self.part_eff = part_eff
self.part_eff_unit = part_eff_unit
self.part_eff_alt = 0
self.part_eff_alt_unit = part_eff_unit
self.compressor_type = compressor_type
self.set_of_curves = set_of_curves
self.part_eff_ref_std = part_eff_ref_std
Expand Down Expand Up @@ -122,9 +126,10 @@ def __init__(
"x2_min": 10,
"x2_max": 40,
"x2_norm": ect,
"nbval": nb_val,
},
"eir-f-f": {"x1_min": 0, "x1_max": 1, "x1_norm": 1, "nbval": nb_val},
"cap-f-f": {"x1_min": 0, "x1_max": 1, "x1_norm": 1, "nbval": nb_val},
"eir-f-ff": {"x1_min": 0, "x1_max": 1, "x1_norm": 1, "nbval": nb_val},
"cap-f-ff": {"x1_min": 0, "x1_max": 1, "x1_norm": 1, "nbval": nb_val},
"plf-f-plr": {"x1_min": 0, "x1_max": 1, "x1_norm": 1, "nbval": nb_val},
}

Expand Down Expand Up @@ -155,18 +160,19 @@ def calc_rated_eff(
plf_f_plr = curves["plf_f_plr"]
tot_cap_flow_mod_fac = cap_f_f.evaluate(1, 1)
eir_flow_mod_fac = eir_f_f.evaluate(1, 1)
num_of_reduced_cap = equipment_references[self.type][std]["coef"][
eqp_type = self.type.lower()
num_of_reduced_cap = equipment_references[eqp_type][std]["coef"][
"numofreducedcap"
]
reduced_plr = equipment_references[self.type][std]["coef"]["reducedplr"]
weighting_factor = equipment_references[self.type][std]["coef"][
reduced_plr = equipment_references[eqp_type][std]["coef"]["reducedplr"]
weighting_factor = equipment_references[eqp_type][std]["coef"][
"weightingfactor"
]
tot_cap_temp_mod_fac = cap_f_t.evaluate(
equipment_references[self.type][std][
equipment_references[eqp_type][std][
"cooling_coil_inlet_air_wet_bulb_rated"
],
equipment_references[self.type][std][
equipment_references[eqp_type][std][
"outdoor_unit_inlet_air_dry_bulb_rated"
],
)
Expand All @@ -183,10 +189,10 @@ def calc_rated_eff(
)
else:
outdoor_unit_inlet_air_dry_bulb_temp_reduced = equipment_references[
self.type
eqp_type
][std]["outdoor_unit_inlet_air_dry_bulb_reduced"]
tot_cap_temp_mod_fac = cap_f_t.evaluate(
equipment_references[self.type][std][
equipment_references[eqp_type][std][
"cooling_coil_inlet_air_wet_bulb_rated"
],
outdoor_unit_inlet_air_dry_bulb_temp_reduced,
Expand All @@ -196,7 +202,7 @@ def calc_rated_eff(
- self.fan_power
)
eir_temp_mod_fac = eir_f_t.evaluate(
equipment_references[self.type][std][
equipment_references[eqp_type][std][
"cooling_coil_inlet_air_wet_bulb_rated"
],
outdoor_unit_inlet_air_dry_bulb_temp_reduced,
Expand Down Expand Up @@ -286,20 +292,16 @@ def get_rated_temperatures(self, alt=False):
std = self.part_eff_ref_std_alt
else:
std = self.part_eff_ref_std
dx_data = equipment_references[self.type][std][self.condenser_type]
# Air Entering Indoor Drybulb
aed = [
Equipment.convert_to_deg_c(t, dx_data["ae_unit"]) for t in dx_data["aed"]
]
# Air Entering Indoor Wetbulb
aew = [
Equipment.convert_to_deg_c(t, dx_data["ae_unit"]) for t in dx_data["aew"]
]
# Outdoor Water/Air entering
dx_data = equipment_references[self.type.lower()][std][self.condenser_type]
# Air entering indoor dry-bulb
aed = Equipment.convert_to_deg_c(dx_data["aed"], dx_data["ae_unit"])
# Air entering indoor wet-bulb
aew = Equipment.convert_to_deg_c(dx_data["aew"], dx_data["ae_unit"])
# Outdoor water/air entering
ect = [
Equipment.convert_to_deg_c(t, dx_data["ect_unit"]) for t in dx_data["ect"]
]
# Outdoor Water/Air leaving
# Outdoor water/air leaving
lct = Equipment.convert_to_deg_c(dx_data["lct"], dx_data["lct_unit"])
return [aed, aew, ect, lct]

Expand Down
27 changes: 27 additions & 0 deletions tests/test_unitarydirectexpansion.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,33 @@ def test_calc_eff_ect(self):
cop_2 = round(DX.calc_rated_eff(), 2)
self.assertTrue(cop_1 == cop_2, f"{cop_1} is different than {cop_2}")

def test_generation(self):
lib = cp.Library(path=DX_lib)
dx_unit = cp.UnitaryDirectExpansion(
compressor_type="scroll",
condenser_type="air",
compressor_speed="constant",
ref_cap_unit="si",
ref_gross_cap=471000,
full_eff=5.89,
full_eff_unit="cop",
part_eff_ref_std="ahri_340/360",
model="simplified_bf",
sim_engine="energyplus",
set_of_curves=lib.get_set_of_curves_by_name("D208122216").curves,
fan_control_mode="constant_speed",
)
dx_unit.part_eff = 8.5
set_of_curves = dx_unit.generate_set_of_curves(
base_curves=[lib.get_set_of_curves_by_name("D208122216")],
tol=0.01,
verbose=True,
vars=["eir-f-t"],
max_gen=300,
max_restart=3,
)
assert len(set_of_curves) == 5

def test_model_type_error(self):
lib = cp.Library(path=DX_lib)
with self.assertLogs(level="ERROR") as log:
Expand Down

0 comments on commit 2cba643

Please sign in to comment.