Skip to content

Commit

Permalink
Merge pull request #111 from pnnl/get_dft_args
Browse files Browse the repository at this point in the history
Automatically retrieve default arguments
  • Loading branch information
aowabinr authored Sep 10, 2024
2 parents 57e5914 + a616103 commit 8fb4f1d
Showing 3 changed files with 28 additions and 6 deletions.
20 changes: 14 additions & 6 deletions copper/library.py
Original file line number Diff line number Diff line change
@@ -172,20 +172,28 @@ def find_set_of_curves_from_lib(self, filters=[], part_eff_flag=False):
class_name = props["eqp_type"][0].upper() + props["eqp_type"][1:]
full_class_path = "copper." + class_name
# Get equipment properties
eqp_props = inspect.getfullargspec(eval(full_class_path).__init__)[0]
eqp_class_info = inspect.getfullargspec(eval(full_class_path).__init__)
sign_eqp_class = inspect.signature(eval(full_class_path).__init__)
eqp_props = eqp_class_info[0]
eqp_props.remove("self")

# List of propeties that should get defaulted
prop_to_default = [
"part_eff_ref_std",
"indoor_fan_speeds_mapping",
"indoor_fan_speeds",
]

# Set the equipment properties
# using values from the library
obj_args = {}
for p in eqp_props:
if not "set_of_curves" in p:
if part_eff_flag and "part_eff" in p:
if p == "part_eff_ref_std":
obj_args["part_eff_ref_std"] = "ahri_550/590"
else:
if p in props.keys():
obj_args[p] = props[p]
if p in props.keys():
obj_args[p] = props[p]
elif p in prop_to_default:
obj_args[p] = sign_eqp_class.parameters[p].default
elif (
"part_eff" in p or "alt" in p or "degradation_coefficient" in p
):
8 changes: 8 additions & 0 deletions tests/test_chiller.py
Original file line number Diff line number Diff line change
@@ -297,3 +297,11 @@ def test_curves_fromm_lib(self):

seed_curve_check = np.asarray(list_of_seed_bools)
self.assertTrue(np.all(seed_curve_check) == True)

def test_lib_default_props_chiller(self):
assert (
self.lib.find_set_of_curves_from_lib(
filters=[("compressor_type", "screw")], part_eff_flag=True
)[0].eqp.__dict__["part_eff_ref_std"]
== "ahri_550/590"
)
6 changes: 6 additions & 0 deletions tests/test_unitarydirectexpansion.py
Original file line number Diff line number Diff line change
@@ -142,6 +142,12 @@ def test_generation(self):
# Check that all curves have been generated
assert len(set_of_curves) == 5

def test_lib_default_props_dx(self):
assert (
self.lib.find_set_of_curves_from_lib()[0].eqp.__dict__["part_eff_ref_std"]
== "ahri_340/360"
)

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

0 comments on commit 8fb4f1d

Please sign in to comment.