Skip to content

Commit

Permalink
Fix prior meta runs
Browse files Browse the repository at this point in the history
  • Loading branch information
ppinchuk committed Jun 13, 2024
1 parent a3cd110 commit 1374937
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 11 deletions.
31 changes: 21 additions & 10 deletions reV/bespoke/bespoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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, "
Expand Down
23 changes: 22 additions & 1 deletion tests/test_bespoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down Expand Up @@ -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])

Expand Down

0 comments on commit 1374937

Please sign in to comment.