def calculate_gen_inv_costs(scenario, year, cost_case, sum_results=True): """Calculate cost of upgrading generators in a scenario. ReEDS regions are used to find regional multipliers. :param powersimdata.scenario.scenario.Scenario scenario: scenario instance. :param int/str year: building year. :param str cost_case: ATB cost case of data. *'Moderate'*: mid cost case, *'Conservative'*: generally higher costs, *'Advanced'*: generally lower costs :param bool sum_results: whether to sum data frame for plant costs. Defaults to True. :return: (*pandas.Series*) -- Overnight generation investment cost. If ``sum_results``, indices are technologies and values are total cost. Otherwise, indices are IDs of plants (including storage, which is given pseudo-plant-IDs), and values are individual generator costs. Whether summed or not, values are $USD, inflation-adjusted to today. .. todo:: it currently uses one (arbitrary) sub-technology. The rest of the costs are dropped. Wind and solar will need to be fixed based on the resource supply curves. """ base_grid = Grid(scenario.info["interconnect"].split("_")) grid = scenario.state.get_grid() # Find change in generation capacity grid_new = cp.deepcopy(grid) # Reindex so that we don't get NaN when calculating upgrades for new generators base_grid.plant = base_grid.plant.reindex(grid_new.plant.index).fillna(0) grid_new.plant.Pmax = grid.plant.Pmax - base_grid.plant.Pmax # Find change in storage capacity # Reindex so that we don't get NaN when calculating upgrades for new storage base_grid.storage["gen"] = base_grid.storage["gen"].reindex( grid_new.storage["gen"].index, fill_value=0 ) grid_new.storage["gen"].Pmax = ( grid.storage["gen"].Pmax - base_grid.storage["gen"].Pmax ) grid_new.storage["gen"]["type"] = "storage" # Drop small changes grid_new.plant = grid_new.plant[grid_new.plant.Pmax > 0.01] costs = _calculate_gen_inv_costs(grid_new, year, cost_case, sum_results) return costs
def calculate_gen_inv_costs(scenario, year, cost_case, sum_results=True): """Given a Scenario object, calculate the total cost of building that scenario's upgrades of generation. Currently only uses one (arbutrary) sub-technology. Drops the rest of the costs. Will want to fix for wind/solar (based on resource supply curves). Currently uses ReEDS regions to find regional multipliers. :param powersimdata.scenario.scenario.Scenario scenario: scenario instance. :param int/str year: year of builds. :param str cost_case: the ATB cost case of data: 'Moderate': mid cost case, 'Conservative': generally higher costs, 'Advanced': generally lower costs :return: (*pandas.DataFrame*) -- Total generation investment cost summed by technology. """ base_grid = Grid(scenario.info["interconnect"].split("_")) grid = scenario.state.get_grid() # Find change in generation capacity grid_new = cp.deepcopy(grid) # Reindex so that we don't get NaN when calculating upgrades for new generators base_grid.plant = base_grid.plant.reindex(grid_new.plant.index).fillna(0) grid_new.plant.Pmax = grid.plant.Pmax - base_grid.plant.Pmax # Find change in storage capacity # Reindex so that we don't get NaN when calculating upgrades for new storage base_grid.storage["gen"] = base_grid.storage["gen"].reindex( grid_new.storage["gen"].index, fill_value=0) grid_new.storage["gen"].Pmax = (grid.storage["gen"].Pmax - base_grid.storage["gen"].Pmax) grid_new.storage["gen"]["type"] = "storage" # Drop small changes grid_new.plant = grid_new.plant[grid_new.plant.Pmax > 0.01] costs = _calculate_gen_inv_costs(grid_new, year, cost_case, sum_results) return costs