Skip to content

Commit

Permalink
Merge pull request #458 from NREL/pp/fix_voc_zero_bug
Browse files Browse the repository at this point in the history
Fix zero cost EOS bug
  • Loading branch information
ppinchuk authored Jun 26, 2024
2 parents 75ccf41 + 5e128cb commit 77f3bb5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 30 deletions.
10 changes: 3 additions & 7 deletions reV/econ/economies_of_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
13 changes: 7 additions & 6 deletions reV/supply_curve/points.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion reV/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
reV Version number
"""

__version__ = "0.9.1"
__version__ = "0.9.2"
30 changes: 14 additions & 16 deletions tests/test_econ_of_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand All @@ -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")
Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand All @@ -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])

Expand Down

0 comments on commit 77f3bb5

Please sign in to comment.