From cbf0372ca2b16c5cf50422cbed8e83463d5636f0 Mon Sep 17 00:00:00 2001 From: ppinchuk Date: Tue, 25 Jun 2024 16:42:48 -0600 Subject: [PATCH 1/6] Default costs to `None`, not 0 --- reV/supply_curve/points.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reV/supply_curve/points.py b/reV/supply_curve/points.py index 5076ac87b..7cb5237fe 100644 --- a/reV/supply_curve/points.py +++ b/reV/supply_curve/points.py @@ -2188,10 +2188,10 @@ def _sam_lcoe_kwargs(self): def _compute_cost_per_ac_mw(self, dset): """Compute a cost per AC MW for a given input. """ if self._sam_system_capacity <= 0: - return 0 + return None if dset not in self.gen.datasets: - return 0 + return None sam_cost = self.exclusion_weighted_mean(self.gen[dset]) sam_cost_per_mw = sam_cost / self._sam_system_capacity From 12e379e2997375c6be3e7f8dd60e505702bb8837 Mon Sep 17 00:00:00 2001 From: ppinchuk Date: Tue, 25 Jun 2024 16:43:07 -0600 Subject: [PATCH 2/6] Only scale not-`None` costs --- reV/supply_curve/points.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/reV/supply_curve/points.py b/reV/supply_curve/points.py index 7cb5237fe..82e905aed 100644 --- a/reV/supply_curve/points.py +++ b/reV/supply_curve/points.py @@ -2391,10 +2391,11 @@ def economies_of_scale(cap_cost_scale, summary): summary[SupplyCurveField.RAW_LCOE] = eos.raw_lcoe summary[SupplyCurveField.MEAN_LCOE] = eos.scaled_lcoe summary[SupplyCurveField.EOS_MULT] = eos.capital_cost_scalar - summary[SupplyCurveField.COST_SITE_OCC_USD_PER_AC_MW] = ( - summary[SupplyCurveField.COST_SITE_OCC_USD_PER_AC_MW] - * summary[SupplyCurveField.EOS_MULT] - ) + cost = summary[SupplyCurveField.COST_SITE_OCC_USD_PER_AC_MW] + if cost is not None: + summary[SupplyCurveField.COST_SITE_OCC_USD_PER_AC_MW] = ( + cost * summary[SupplyCurveField.EOS_MULT] + ) return summary @classmethod From 5f135c34358e7571ad1fca6b730b2a607fe61d22 Mon Sep 17 00:00:00 2001 From: ppinchuk Date: Tue, 25 Jun 2024 16:43:47 -0600 Subject: [PATCH 3/6] Use site costs for consistency --- reV/econ/economies_of_scale.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reV/econ/economies_of_scale.py b/reV/econ/economies_of_scale.py index 5db110910..8eb1b3a64 100644 --- a/reV/econ/economies_of_scale.py +++ b/reV/econ/economies_of_scale.py @@ -278,7 +278,7 @@ def foc(self): Fixed operating cost from input data arg """ foc_from_cap = self._cost_from_cap( - SupplyCurveField.COST_BASE_FOC_USD_PER_AC_MW + SupplyCurveField.COST_SITE_FOC_USD_PER_AC_MW ) if foc_from_cap is not None: return foc_from_cap @@ -297,7 +297,7 @@ def voc(self): Variable operating cost from input data arg """ voc_from_cap = self._cost_from_cap( - SupplyCurveField.COST_BASE_VOC_USD_PER_AC_MW + SupplyCurveField.COST_SITE_VOC_USD_PER_AC_MW ) if voc_from_cap is not None: return voc_from_cap From 2e7b05f142b66556f62ffd095b11b0ca8abcb877 Mon Sep 17 00:00:00 2001 From: ppinchuk Date: Tue, 25 Jun 2024 16:44:01 -0600 Subject: [PATCH 4/6] Treat 0 costs like all others --- reV/econ/economies_of_scale.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/reV/econ/economies_of_scale.py b/reV/econ/economies_of_scale.py index 8eb1b3a64..88f21f9ef 100644 --- a/reV/econ/economies_of_scale.py +++ b/reV/econ/economies_of_scale.py @@ -212,11 +212,7 @@ def _cost_from_cap(self, col_name): if cost_per_mw is None: return None - cost = cap * cost_per_mw - if cost > 0: - return cost - - return None + return cap * cost_per_mw @property def raw_capital_cost(self): From 39d57d34bc7d592a13abdde1c94b92a36dff874d Mon Sep 17 00:00:00 2001 From: ppinchuk Date: Tue, 25 Jun 2024 16:44:32 -0600 Subject: [PATCH 5/6] Fix up tests --- tests/test_econ_of_scale.py | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/tests/test_econ_of_scale.py b/tests/test_econ_of_scale.py index 2186aaa0e..da27e676c 100644 --- a/tests/test_econ_of_scale.py +++ b/tests/test_econ_of_scale.py @@ -126,7 +126,8 @@ def test_lcoe_calc_simple(): assert np.allclose(eos.scaled_lcoe, true_scaled, rtol=0.001) -def test_econ_of_scale_baseline(): +@pytest.mark.parametrize("request_h5", [True, False]) +def test_econ_of_scale_baseline(request_h5): """Test an economies of scale calculation with scalar = 1 to ensure we can reproduce the lcoe values """ @@ -137,6 +138,11 @@ def test_econ_of_scale_baseline(): "system_capacity": 20000, "variable_operating_cost": 0, } + h5_dsets = None + if request_h5: + h5_dsets = ["capital_cost", "fixed_operating_cost", + "fixed_charge_rate", "variable_operating_cost"] + with tempfile.TemporaryDirectory() as td: gen_temp = os.path.join(td, "ri_my_pv_gen.h5") @@ -172,12 +178,7 @@ def test_econ_of_scale_baseline(): res_class_bins=RES_CLASS_BINS, data_layers=DATA_LAYERS, gids=list(np.arange(10)), - h5_dsets=[ - "capital_cost", - "fixed_operating_cost", - "fixed_charge_rate", - "variable_operating_cost" - ], + h5_dsets=h5_dsets, ) base.run(out_fp_base, gen_fpath=gen_temp, max_workers=1) @@ -191,12 +192,7 @@ def test_econ_of_scale_baseline(): data_layers=DATA_LAYERS, gids=list(np.arange(10)), cap_cost_scale="1", - h5_dsets=[ - "capital_cost", - "fixed_operating_cost", - "fixed_charge_rate", - "variable_operating_cost" - ], + h5_dsets=h5_dsets, ) sc.run(out_fp_sc, gen_fpath=gen_temp, max_workers=1) @@ -205,9 +201,11 @@ def test_econ_of_scale_baseline(): assert np.allclose(base_df[SupplyCurveField.MEAN_LCOE], sc_df[SupplyCurveField.MEAN_LCOE]) assert (sc_df[SupplyCurveField.EOS_MULT] == 1).all() - assert np.allclose(sc_df['mean_capital_cost'], - sc_df[SupplyCurveField.COST_SITE_OCC_USD_PER_AC_MW] - * 20000) + if "mean_capital_cost" in sc_df: + capital_cost_per_mw = SupplyCurveField.COST_SITE_OCC_USD_PER_AC_MW + assert np.allclose(sc_df['mean_capital_cost'], + sc_df[capital_cost_per_mw] + * data["system_capacity"]) assert np.allclose(sc_df[SupplyCurveField.COST_BASE_OCC_USD_PER_AC_MW], sc_df[SupplyCurveField.COST_SITE_OCC_USD_PER_AC_MW]) From 5e128cb9e297755c472cec5292beeea51b647ebe Mon Sep 17 00:00:00 2001 From: ppinchuk Date: Tue, 25 Jun 2024 16:44:50 -0600 Subject: [PATCH 6/6] Bump reV version --- reV/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reV/version.py b/reV/version.py index c242d7808..296165197 100644 --- a/reV/version.py +++ b/reV/version.py @@ -2,4 +2,4 @@ reV Version number """ -__version__ = "0.9.1" +__version__ = "0.9.2"