diff --git a/reV/econ/economies_of_scale.py b/reV/econ/economies_of_scale.py index 5db110910..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): @@ -278,7 +274,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 +293,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 diff --git a/reV/supply_curve/points.py b/reV/supply_curve/points.py index 5076ac87b..82e905aed 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 @@ -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 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" 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])