From 137493714b7e2a138a39cbebf9d0a9341c79bd39 Mon Sep 17 00:00:00 2001 From: ppinchuk Date: Wed, 12 Jun 2024 18:08:12 -0600 Subject: [PATCH] Fix prior meta runs --- reV/bespoke/bespoke.py | 31 +++++++++++++++++++++---------- tests/test_bespoke.py | 23 ++++++++++++++++++++++- 2 files changed, 43 insertions(+), 11 deletions(-) diff --git a/reV/bespoke/bespoke.py b/reV/bespoke/bespoke.py index 6211a375e..4e5b73a16 100644 --- a/reV/bespoke/bespoke.py +++ b/reV/bespoke/bespoke.py @@ -1094,17 +1094,23 @@ def get_lcoe_kwargs(self): plant_optimizer, original_sam_sys_inputs, meta """ - kwargs_list = [ - "fixed_charge_rate", - "system_capacity", - "capital_cost", - "fixed_operating_cost", - "variable_operating_cost", - "balance_of_system_cost", - ] + kwargs_map = { + "fixed_charge_rate": SupplyCurveField.FIXED_CHARGE_RATE, + "system_capacity": SupplyCurveField.CAPACITY_AC_MW, + "capital_cost": SupplyCurveField.BESPOKE_CAPITAL_COST, + "fixed_operating_cost": ( + SupplyCurveField.BESPOKE_FIXED_OPERATING_COST + ), + "variable_operating_cost": ( + SupplyCurveField.BESPOKE_VARIABLE_OPERATING_COST + ), + "balance_of_system_cost": ( + SupplyCurveField.BESPOKE_BALANCE_OF_SYSTEM_COST + ), + } lcoe_kwargs = {} - for kwarg in kwargs_list: + for kwarg, meta_field in kwargs_map.items(): if kwarg in self.outputs: lcoe_kwargs[kwarg] = self.outputs[kwarg] elif getattr(self.plant_optimizer, kwarg, None) is not None: @@ -1114,8 +1120,13 @@ def get_lcoe_kwargs(self): elif kwarg in self.meta: value = float(self.meta[kwarg].values[0]) lcoe_kwargs[kwarg] = value + elif meta_field in self.meta: + value = float(self.meta[meta_field].values[0]) + if meta_field == SupplyCurveField.CAPACITY_AC_MW: + value *= 1000 # MW to kW + lcoe_kwargs[kwarg] = value - missing = [k for k in kwargs_list if k not in lcoe_kwargs] + missing = [k for k in kwargs_map if k not in lcoe_kwargs] if any(missing): msg = ( "Could not find these LCOE kwargs in outputs, " diff --git a/tests/test_bespoke.py b/tests/test_bespoke.py index 0f338872c..c44120d96 100644 --- a/tests/test_bespoke.py +++ b/tests/test_bespoke.py @@ -565,7 +565,7 @@ def test_extra_outputs(gid=33): bsp.close() -def test_bespok_kjbndkjnbdfkjne(): +def test_bespoke(): """Test bespoke optimization with multiple plants, parallel processing, and file output.""" output_request = ( @@ -1253,6 +1253,27 @@ def test_bespoke_prior_run(): SupplyCurveField.N_GIDS, SupplyCurveField.GID_COUNTS, SupplyCurveField.RES_GIDS, + SupplyCurveField.N_TURBINES, + SupplyCurveField.EOS_MULT, + SupplyCurveField.REG_MULT, + SupplyCurveField.INCLUDED_AREA, + SupplyCurveField.INCLUDED_AREA_CAPACITY_DENSITY, + SupplyCurveField.CONVEX_HULL_AREA, + SupplyCurveField.CONVEX_HULL_CAPACITY_DENSITY, + SupplyCurveField.FULL_CELL_CAPACITY_DENSITY, + SupplyCurveField.COST_BASE_OCC_USD_PER_AC_MW, + SupplyCurveField.COST_SITE_OCC_USD_PER_AC_MW, + SupplyCurveField.COST_BASE_FOC_USD_PER_AC_MW, + SupplyCurveField.COST_SITE_FOC_USD_PER_AC_MW, + SupplyCurveField.COST_BASE_VOC_USD_PER_AC_MW, + SupplyCurveField.COST_SITE_VOC_USD_PER_AC_MW, + SupplyCurveField.FIXED_CHARGE_RATE, + SupplyCurveField.BESPOKE_AEP, + SupplyCurveField.BESPOKE_OBJECTIVE, + SupplyCurveField.BESPOKE_CAPITAL_COST, + SupplyCurveField.BESPOKE_FIXED_OPERATING_COST, + SupplyCurveField.BESPOKE_VARIABLE_OPERATING_COST, + SupplyCurveField.BESPOKE_BALANCE_OF_SYSTEM_COST, ] pd.testing.assert_frame_equal(meta1[cols], meta2[cols])