Skip to content

Commit

Permalink
Cleanup and black formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
lymereJ committed Mar 3, 2025
1 parent 29c2697 commit 817cb98
Show file tree
Hide file tree
Showing 7 changed files with 433 additions and 227 deletions.
9 changes: 8 additions & 1 deletion copper/chiller.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,14 @@ def calc_eff_ect(self, cap_f_t, eir_f_t, eir_f_plr, eir_ref, ect, lwt, load):

return eir

def calc_rated_eff(self, eff_type, unit="kW/ton", output_report=False, alt=False, apply_modifiers_at_full_load = True):
def calc_rated_eff(
self,
eff_type,
unit="kW/ton",
output_report=False,
alt=False,
apply_modifiers_at_full_load=True,
):
"""Calculate chiller efficiency.
:param str eff_type: Chiller efficiency type, currently supported `full` (full load rating)
Expand Down
11 changes: 4 additions & 7 deletions copper/curves.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,10 +723,7 @@ def evaluate(self, x, y):
out = self.coeff1 + self.coeff2 * x + self.coeff3 * x**2
if self.type == "cubic":
out = (
self.coeff1
+ self.coeff2 * x
+ self.coeff3 * x**2
+ self.coeff4 * x**3
self.coeff1 + self.coeff2 * x + self.coeff3 * x**2 + self.coeff4 * x**3
)
if self.type == "linear":
out = self.coeff1 + self.coeff2 * x
Expand Down Expand Up @@ -755,9 +752,9 @@ def compute_grad(self, x, y, sign_val, threshold=1e-5):
grad = np.around(
np.gradient(y, x), 2
) # add a small number to get rid of very small negative values
grad[
np.abs(grad) <= threshold
] = 0 # making sure that small gradients are set to zero to avoid
grad[np.abs(grad) <= threshold] = (
0 # making sure that small gradients are set to zero to avoid
)
sign = np.sign(grad)

if np.all(np.asarray(y) == 0): # all values are false
Expand Down
72 changes: 52 additions & 20 deletions copper/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ def generate_set_of_curves(self, verbose=False, agg_only=False):
self.set_of_base_curves.eqp.set_of_curves = self.set_of_base_curves.curves
self.base_curves_data = {}
for curve in self.set_of_base_curves.curves:
self.base_curves_data[
curve.out_var
] = self.set_of_base_curves.get_data_for_plotting(curve, False)
self.base_curves_data[curve.out_var] = (
self.set_of_base_curves.get_data_for_plotting(curve, False)
)

# Return if aggregation is only needed
if agg_only:
Expand Down Expand Up @@ -179,13 +179,17 @@ def run_ga(self, curves, verbose=False):
full_rating_alt = "n/a"
part_eff = round(
self.equipment.calc_rated_eff(
eff_type="part", unit=self.equipment.part_eff_unit, apply_modifiers_at_full_load=True
eff_type="part",
unit=self.equipment.part_eff_unit,
apply_modifiers_at_full_load=True,
),
4,
)
full_eff = round(
self.equipment.calc_rated_eff(
eff_type="full", unit=self.equipment.full_eff_unit, apply_modifiers_at_full_load=True
eff_type="full",
unit=self.equipment.full_eff_unit,
apply_modifiers_at_full_load=True,
),
4,
)
Expand All @@ -204,13 +208,17 @@ def run_ga(self, curves, verbose=False):
restart += 1
part_eff = round(
self.equipment.calc_rated_eff(
eff_type="part", unit=self.equipment.part_eff_unit, apply_modifiers_at_full_load=True
eff_type="part",
unit=self.equipment.part_eff_unit,
apply_modifiers_at_full_load=True,
),
4,
)
full_eff = round(
self.equipment.calc_rated_eff(
eff_type="full", unit=self.equipment.full_eff_unit, apply_modifiers_at_full_load=True
eff_type="full",
unit=self.equipment.full_eff_unit,
apply_modifiers_at_full_load=True,
),
4,
)
Expand Down Expand Up @@ -241,20 +249,30 @@ def is_target_met(self):
if self.equipment.type == "chiller":
if self.equipment.set_of_curves != "":
part_rating = self.equipment.calc_rated_eff(
eff_type="part", unit=self.equipment.part_eff_unit, apply_modifiers_at_full_load=True
eff_type="part",
unit=self.equipment.part_eff_unit,
apply_modifiers_at_full_load=True,
)
full_rating = self.equipment.calc_rated_eff(
eff_type="full", unit=self.equipment.full_eff_unit, apply_modifiers_at_full_load=True
eff_type="full",
unit=self.equipment.full_eff_unit,
apply_modifiers_at_full_load=True,
)
if self.target_alt > 0:
part_rating_alt = self.equipment.calc_rated_eff(
eff_type="part", unit=self.equipment.part_eff_unit_alt, alt=True, apply_modifiers_at_full_load=True
eff_type="part",
unit=self.equipment.part_eff_unit_alt,
alt=True,
apply_modifiers_at_full_load=True,
)
else:
part_rating_alt = 0
if self.full_eff_alt > 0:
full_rating_alt = self.equipment.calc_rated_eff(
eff_type="full", unit=self.equipment.full_eff_unit_alt, alt=True, apply_modifiers_at_full_load=True
eff_type="full",
unit=self.equipment.full_eff_unit_alt,
alt=True,
apply_modifiers_at_full_load=True,
)
else:
full_rating_alt = 0
Expand All @@ -269,12 +287,16 @@ def is_target_met(self):
elif self.equipment.type == "UnitaryDirectExpansion":
if self.equipment.set_of_curves != "":
part_rating = self.equipment.calc_rated_eff(
eff_type="part", unit=self.equipment.part_eff_unit, apply_modifiers_at_full_load=True
eff_type="part",
unit=self.equipment.part_eff_unit,
apply_modifiers_at_full_load=True,
)
part_rating_alt = 0
full_rating_alt = 0
full_rating = self.equipment.calc_rated_eff(
eff_type="full", unit=self.equipment.part_eff_unit, apply_modifiers_at_full_load=True
eff_type="full",
unit=self.equipment.part_eff_unit,
apply_modifiers_at_full_load=True,
)
cap_rating = 0
else:
Expand Down Expand Up @@ -343,9 +365,9 @@ def compute_grad(self, x, y, sign_val, threshold=1e-5):
grad = np.around(
np.gradient(y, x), 2
) # add a small number to get rid of very small negative values
grad[
np.abs(grad) <= threshold
] = 0 # making sure that small gradients are set to zero to avoid
grad[np.abs(grad) <= threshold] = (
0 # making sure that small gradients are set to zero to avoid
)
sign = np.sign(grad)

if np.all(np.asarray(y) == 0): # all values are false
Expand Down Expand Up @@ -531,14 +553,19 @@ def determine_part_load_fitness(self, set_of_curves):
self.equipment.set_of_curves = set_of_curves.curves
part_eff_score = abs(
self.equipment.calc_rated_eff(
eff_type="part", unit=self.equipment.part_eff_unit, apply_modifiers_at_full_load=True
eff_type="part",
unit=self.equipment.part_eff_unit,
apply_modifiers_at_full_load=True,
)
- self.target
)
if self.target_alt > 0:
part_eff_score += abs(
self.equipment.calc_rated_eff(
eff_type="part", unit=self.equipment.part_eff_unit_alt, alt=True, apply_modifiers_at_full_load=True
eff_type="part",
unit=self.equipment.part_eff_unit_alt,
alt=True,
apply_modifiers_at_full_load=True,
)
- self.target_alt
)
Expand All @@ -556,14 +583,19 @@ def determine_full_load_fitness(self, set_of_curves):
self.equipment.set_of_curves = set_of_curves.curves
full_eff_score = abs(
self.equipment.calc_rated_eff(
eff_type="full", unit=self.equipment.full_eff_unit, apply_modifiers_at_full_load=True
eff_type="full",
unit=self.equipment.full_eff_unit,
apply_modifiers_at_full_load=True,
)
- self.equipment.full_eff
)
if self.equipment.full_eff_alt > 0:
full_eff_score += abs(
self.equipment.calc_rated_eff(
eff_type="full", unit=self.equipment.full_eff_unit_alt, alt=True, apply_modifiers_at_full_load=True
eff_type="full",
unit=self.equipment.full_eff_unit_alt,
alt=True,
apply_modifiers_at_full_load=True,
)
- self.equipment.full_eff_alt
)
Expand Down
6 changes: 0 additions & 6 deletions copper/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ def __init__(self, path=chiller_lib, rating_std="", export=False):
and not "indoor_fan_curve_coef" in p
and not "indoor_fan_curve" in p
and not "indoor_fan_power_unit" in p
and not "compressor_stage" in p
and not "compressor_stage_input" in p
):
obj_args[p] = vals[p]
elif (
Expand Down Expand Up @@ -125,8 +123,6 @@ def load_obj(self, data):
and not "indoor_fan_curve_coef" in p
and not "indoor_fan_curve" in p
and not "indoor_fan_power_unit" in p
and not "compressor_stage" in p
and not "compressor_stage_input" in p
):
obj_args[p] = data[p]

Expand Down Expand Up @@ -203,8 +199,6 @@ def find_set_of_curves_from_lib(self, filters=[], part_eff_flag=False):
"indoor_fan_speeds",
"indoor_fan_curve_coef",
"indoor_fan_power_unit",
"compressor_stage",
"compressor_stage_input",
]

# Set the equipment properties
Expand Down
Loading

0 comments on commit 817cb98

Please sign in to comment.