def test_creation_of_parameter_names_2022(self): PredictPlant = PredictModernPlantParameters("CCGT", 1200, 2022) cost_parameter_variables = PredictPlant._create_parameter_names(self.initial_stub_cost_parameters) assert cost_parameter_variables == ['Connect_system_cost-Medium _2020', 'Constr_cost-Medium _2020', 'Fixed_cost-Medium _2020', 'Infra_cost-Medium _2020', 'Insurance_cost-Medium _2020', 'Pre_dev_cost-Medium _2020', 'Var_cost-Medium _2020']
def _select_cost_estimator(start_year, plant_type, capacity): earliest_modern_plant_year = min([ int(column.split(" _")[1]) for column in elecsim.scenario.scenario_data.modern_plant_costs.filter( regex='Connect_system_cost-Medium _').columns ]) _check_digit(capacity, "capacity") _check_digit(start_year, "start_year") _check_positive(start_year, "start_year") _check_positive(capacity, "capacity") hist_costs = elecsim.scenario.scenario_data.power_plant_historical_costs_long hist_costs = hist_costs[hist_costs.Technology.map( lambda x: x in plant_type)].dropna() if start_year < earliest_modern_plant_year and not hist_costs.empty: require_fuel = PlantRegistry(plant_type).check_if_fuel_required() cost_parameters = _estimate_old_plant_cost_parameters( capacity, plant_type, require_fuel, start_year) _check_parameters(capacity, cost_parameters, plant_type, start_year) return cost_parameters else: cost_parameters = PredictModernPlantParameters( plant_type, capacity, start_year).parameter_estimation() _check_parameters(capacity, cost_parameters, plant_type, start_year) return cost_parameters
def test_check_plant_exists_fails_with_no_data(self): with pytest.raises(ValueError) as excinfo: PredictModernPlantParameters("Fake_Plant", 1200, 2018).check_plant_exists( {'connection_cost_per_mw': 0, 'construction_cost_per_mw': 0, 'fixed_o_and_m_per_mw': 0, 'infrastructure': 0, 'insurance_cost_per_mw': 0, 'pre_dev_cost_per_mw': 0, 'variable_o_and_m_per_mwh': 0, 'pre_dev_period': 0, 'operating_period': 0, 'construction_period': 0, 'efficiency': 0, 'average_load_factor': 0, 'construction_spend_years': 0, 'pre_dev_spend_years': 0}) assert "No cost data for power plant of type: Fake_Plant" in str(excinfo.value)
def test_estimate_non_interpolatable_parameters_for_ccgt_1450(self): predict_modern_parameters = PredictModernPlantParameters("CCGT", 1450, 2018) assert predict_modern_parameters._estimate_non_interpolatable_parameters("Pre_Dur") == 3 assert predict_modern_parameters._estimate_non_interpolatable_parameters("Operating_Period") ==25 assert predict_modern_parameters._estimate_non_interpolatable_parameters("Constr_Dur") == 3 assert predict_modern_parameters._estimate_non_interpolatable_parameters("Efficiency") == 0.53 assert predict_modern_parameters._estimate_non_interpolatable_parameters("Average_Load_Factor") == 0.93
def calculate_latest_lcoe(self): logging.info('Selecting latest power plant data') estimated_cost_parameters = PredictModernPlantParameters( "PV", 50, 2020).parameter_estimation() power_plant_obj = PlantRegistry("PV").plant_type_to_plant_object() power_plant = power_plant_obj(name="Test", plant_type="PV", capacity_mw=50, construction_year=2020, **estimated_cost_parameters) lcoe = power_plant.calculate_lcoe(0.05) return lcoe
def test_parameter_estimation_for_ccgt_1335_5(self): estimated_plant_parameters = PredictModernPlantParameters("CCGT", 1335.5, 2018).parameter_estimation() assert estimated_plant_parameters['connection_cost_per_mw'] == 3300 assert estimated_plant_parameters['construction_cost_per_mw'] == 500000 assert estimated_plant_parameters['fixed_o_and_m_per_mw'] == 11800 assert estimated_plant_parameters['infrastructure'] == 15100 assert estimated_plant_parameters['insurance_cost_per_mw'] == 2000 assert estimated_plant_parameters['pre_dev_cost_per_mw'] == 10000 assert estimated_plant_parameters['variable_o_and_m_per_mwh'] == 3.00 assert estimated_plant_parameters['pre_dev_period'] == 3 assert estimated_plant_parameters['operating_period'] == 25 assert estimated_plant_parameters['construction_period'] == 3 assert estimated_plant_parameters['efficiency'] == 0.54 assert estimated_plant_parameters['average_load_factor'] == 0.93 assert estimated_plant_parameters['construction_spend_years'] == [0.4, 0.4, 0.2] assert estimated_plant_parameters['pre_dev_spend_years'] == [0.44, 0.44, 0.12]
def __init__(self, year, plant_type, capacity): # Import historical LCOE data for power plants, and use to predict LCOE for current year based on linear # interpolation self.year = year self.plant_type = plant_type self.capacity = capacity self.hist_costs = self.hist_costs[self.hist_costs['Technology'].map( lambda x: x in plant_type)].dropna() if not all(self.hist_costs.capacity_range.str.contains(">0")): self.hist_costs = self.hist_costs[[ pd.eval(f"{self.capacity}{j}") for j in self.hist_costs['capacity_range'] ]] self.estimated_historical_lcoe = ExtrapolateInterpolate( self.hist_costs.Year, self.hist_costs.lcoe)(year) self.discount_rate = self.hist_costs.Discount_rate.iloc[0] self.modern_costs = elecsim.scenario.scenario_data.modern_plant_costs[ elecsim.scenario.scenario_data.modern_plant_costs['Type'].map( lambda x: x in plant_type)] minimum_year = self.find_smallest_year_available() self.estimated_modern_plant_parameters = PredictModernPlantParameters( self.plant_type, self.capacity, minimum_year).parameter_estimation() plant_object = PlantRegistry( self.plant_type).plant_type_to_plant_object() self.plant = plant_object(name="Modern Plant", plant_type=self.plant_type, capacity_mw=self.capacity, construction_year=self.year, **self.estimated_modern_plant_parameters) self.modern_lcoe = self.plant.calculate_lcoe(self.discount_rate) self.lcoe_scaler = self.estimated_historical_lcoe / self.modern_lcoe
def test_payment_spread_estimator_for_ccgt_160(self): predict_modern_parameters = PredictModernPlantParameters("CCGT", 160, 2018) assert predict_modern_parameters._payment_spread_estimator("Constr") == [0.4, 0.4, 0.2] assert predict_modern_parameters._payment_spread_estimator("Pre") == [0.435, 0.435, 0.13]
def test_check_plant_exists_with_data(self): PredictModernPlantParameters("Fake_Plant", 1200, 2018).check_plant_exists( {'connection_cost_per_mw': 100, 'construction_cost_per_mw': 100, 'fixed_o_and_m_per_mw': 100, 'infrastructure': 100, 'insurance_cost_per_mw': 100, 'pre_dev_cost_per_mw': 100, 'variable_o_and_m_per_mwh': 100, 'pre_dev_period': 100, 'operating_period': 100, 'construction_period': 100, 'efficiency': 100, 'average_load_factor': 100, 'construction_spend_years': 100, 'pre_dev_spend_years': 100})