diff --git a/data_energy/techno_invests/cleanenergysimpletechno.csv b/data_energy/techno_invests/cleanenergysimpletechno.csv index 80cf6795..095e7a6f 100644 --- a/data_energy/techno_invests/cleanenergysimpletechno.csv +++ b/data_energy/techno_invests/cleanenergysimpletechno.csv @@ -1,10 +1,10 @@ years,invest -2015,1074 -2016,1132 -2017,1129 -2018,1137 -2019,1225 -2020,1259 -2021,1408 -2022,1617 -2023,1740 +2015,394 +2016,401 +2017,403 +2018,427 +2019,473 +2020,500 +2021,539 +2022,687 +2023,822 diff --git a/data_energy/techno_invests/sources.txt b/data_energy/techno_invests/sources.txt index a389324b..d36b6195 100644 --- a/data_energy/techno_invests/sources.txt +++ b/data_energy/techno_invests/sources.txt @@ -1,5 +1,5 @@ FossilSimpleTechno : https://www.iea.org/reports/world-energy-investment-2023/overview-and-key-findings -RenewableSimpleTechno : https://www.iea.org/reports/world-energy-investment-2023/overview-and-key-findings +RenewableSimpleTechno : https://www.iea.org/data-and-statistics/charts/global-investment-in-clean-energy-and-fossil-fuels-2015-2024 CarbonStorageTechno : https://www.iea.org/energy-system/carbon-capture-utilisation-and-storage/co2-capture-and-utilisation DirectAirCaptureTechno : https://www.iea.org/energy-system/carbon-capture-utilisation-and-storage/direct-air-capture SolarPV: [https://www.iea.org/energy-system/renewables/solar-pv,] diff --git a/energy_models/core/ccus/ccus_disc.py b/energy_models/core/ccus/ccus_disc.py index 31463b1f..c17e862c 100644 --- a/energy_models/core/ccus/ccus_disc.py +++ b/energy_models/core/ccus/ccus_disc.py @@ -64,11 +64,8 @@ class CCUS_Discipline(SoSWrapp): 'visibility': SoSWrapp.SHARED_VISIBILITY, 'namespace': 'ns_public'}, 'scaling_factor_energy_consumption': {'type': 'float', 'default': 1e3, 'unit': '-', 'user_level': 2, 'visibility': SoSWrapp.SHARED_VISIBILITY, 'namespace': 'ns_public'}, - 'carbonstorage_limit': {'type': 'float', 'default': 12e6, 'unit': 'Mt', 'user_level': 2, - 'visibility': SoSWrapp.SHARED_VISIBILITY, 'namespace': GlossaryEnergy.NS_REFERENCE}, - 'carbonstorage_constraint_ref': {'type': 'float', 'default': 12e6, 'unit': 'Mt', 'user_level': 2, - 'visibility': SoSWrapp.SHARED_VISIBILITY, - 'namespace': GlossaryEnergy.NS_REFERENCE}, + 'carbonstorage_limit': {'type': 'float', 'default': 12e6, 'unit': 'Mt', 'user_level': 2,}, + 'carbonstorage_constraint_ref': {'type': 'float', 'default': 12e6, 'unit': 'Mt', 'user_level': 2}, 'co2_emissions_needed_by_energy_mix': {'type': 'dataframe', 'unit': 'Gt', 'visibility': SoSWrapp.SHARED_VISIBILITY, 'namespace': 'ns_energy', 'dataframe_descriptor': {GlossaryEnergy.Years: ('float', None, True), diff --git a/energy_models/core/demand/energy_demand_disc.py b/energy_models/core/demand/energy_demand_disc.py index 7eb3ab40..985b6126 100644 --- a/energy_models/core/demand/energy_demand_disc.py +++ b/energy_models/core/demand/energy_demand_disc.py @@ -58,17 +58,13 @@ class EnergyDemandDiscipline(SoSWrapp): # old value is 20900TWh 'initial_electricity_demand': {'type': 'float', 'default': 18000., 'unit': 'TWh'}, 'long_term_elec_machine_efficiency': {'type': 'float', 'default': 0.985, 'unit': '-'}, - 'electricity_demand_constraint_ref': {'type': 'float', 'default': 2500.0, 'unit': 'TWh', - 'visibility': SoSWrapp.SHARED_VISIBILITY, - 'namespace': GlossaryEnergy.NS_REFERENCE}, + 'electricity_demand_constraint_ref': {'type': 'float', 'default': 2500.0, 'unit': 'TWh',}, GlossaryEnergy.PopulationDf['var_name']: GlossaryEnergy.PopulationDf, GlossaryEnergy.TransportDemandValue: {'type': 'dataframe', 'dataframe_descriptor': { GlossaryEnergy.Years: ('int', [1900, GlossaryEnergy.YearEndDefaultCore], False), GlossaryEnergy.TransportDemandValue: ('float', None, True)}, 'dataframe_edition_locked': False, 'unit': 'TWh'}, - 'transport_demand_constraint_ref': {'type': 'float', 'default': 6000.0, 'unit': 'TWh', - 'visibility': SoSWrapp.SHARED_VISIBILITY, - 'namespace': GlossaryEnergy.NS_REFERENCE}, + 'transport_demand_constraint_ref': {'type': 'float', 'default': 6000.0, 'unit': 'TWh',}, 'additional_demand_transport': {'type': 'float', 'default': 10., 'unit': '%'}} DESC_OUT = { diff --git a/energy_models/core/energy_ghg_emissions/energy_ghg_emissions_disc.py b/energy_models/core/energy_ghg_emissions/energy_ghg_emissions_disc.py index 2df2985e..7a2767ef 100644 --- a/energy_models/core/energy_ghg_emissions/energy_ghg_emissions_disc.py +++ b/energy_models/core/energy_ghg_emissions/energy_ghg_emissions_disc.py @@ -55,7 +55,7 @@ class EnergyGHGEmissionsDiscipline(SoSWrapp): 'last_modification_date': '', 'category': '', 'definition': '', - 'icon': 'fas fa-cloud fa-fw', + 'icon': "fa-solid fa-bolt", 'version': '', } diff --git a/energy_models/core/energy_mix/energy_mix_disc.py b/energy_models/core/energy_mix/energy_mix_disc.py index 4d57d3f2..7d96a50c 100644 --- a/energy_models/core/energy_mix/energy_mix_disc.py +++ b/energy_models/core/energy_mix/energy_mix_disc.py @@ -82,7 +82,7 @@ class Energy_Mix_Discipline(SoSWrapp): 'last_modification_date': '', 'category': '', 'definition': '', - 'icon': 'fas fa-battery-full fa-fw', + 'icon': "fa-solid fa-bolt", 'version': '', } # All values used to calibrate heat loss percentage @@ -117,19 +117,13 @@ class Energy_Mix_Discipline(SoSWrapp): GlossaryEnergy.EnergyMeanPriceObjectiveRefValue: GlossaryEnergy.EnergyMeanPriceObjectiveRef, 'alpha': {'type': 'float', 'range': [0., 1.], 'default': 0.5, 'unit': '-', 'visibility': SoSWrapp.SHARED_VISIBILITY, 'namespace': 'ns_energy_study'}, - 'primary_energy_percentage': {'type': 'float', 'range': [0., 1.], 'unit': '-', 'default': 0.8, - 'visibility': SoSWrapp.SHARED_VISIBILITY, - 'namespace': GlossaryEnergy.NS_REFERENCE}, - 'normalization_value_demand_constraints': {'type': 'float', 'default': 1000.0, 'unit': 'Twh', - 'visibility': SoSWrapp.SHARED_VISIBILITY, - 'namespace': GlossaryEnergy.NS_REFERENCE}, + 'primary_energy_percentage': {'type': 'float', 'range': [0., 1.], 'unit': '-', 'default': 0.8}, + 'normalization_value_demand_constraints': {'type': 'float', 'default': 1000.0, 'unit': 'Twh'}, GlossaryEnergy.CO2Taxes['var_name']: GlossaryEnergy.CO2Taxes, 'minimum_energy_production': {'type': 'float', 'default': 1e4, 'visibility': SoSWrapp.SHARED_VISIBILITY, 'namespace': 'ns_public', 'unit': 'TWh'}, - 'total_prod_minus_min_prod_constraint_ref': {'type': 'float', 'default': 1e4, 'unit': 'Twh', - 'visibility': SoSWrapp.SHARED_VISIBILITY, - 'namespace': GlossaryEnergy.NS_REFERENCE}, + 'total_prod_minus_min_prod_constraint_ref': {'type': 'float', 'default': 1e4, 'unit': 'Twh'}, 'exp_min': {'type': 'bool', 'default': True, 'user_level': 2}, 'production_threshold': {'type': 'float', 'default': 1e-3, 'unit': 'Twh'}, 'scaling_factor_energy_production': {'type': 'float', 'default': 1e3, 'unit': '-', 'user_level': 2, @@ -138,29 +132,16 @@ class Energy_Mix_Discipline(SoSWrapp): 'scaling_factor_energy_consumption': {'type': 'float', 'default': 1e3, 'unit': '-', 'user_level': 2, 'visibility': SoSWrapp.SHARED_VISIBILITY, 'namespace': 'ns_public'}, - 'solid_fuel_elec_percentage': {'type': 'float', 'default': 0.75, 'unit': '-', 'user_level': 2, - 'visibility': SoSWrapp.SHARED_VISIBILITY, - 'namespace': GlossaryEnergy.NS_REFERENCE}, - 'solid_fuel_elec_constraint_ref': {'type': 'float', 'default': 10000., 'unit': 'Twh', 'user_level': 2, - 'visibility': SoSWrapp.SHARED_VISIBILITY, - 'namespace': GlossaryEnergy.NS_REFERENCE}, - 'liquid_hydrogen_percentage': {'type': 'array', 'user_level': 2, 'unit': '%', - 'visibility': SoSWrapp.SHARED_VISIBILITY, - 'namespace': GlossaryEnergy.NS_REFERENCE}, - 'liquid_hydrogen_constraint_ref': {'type': 'float', 'default': 1000., 'unit': 'Twh', 'user_level': 2, - 'visibility': SoSWrapp.SHARED_VISIBILITY, - 'namespace': GlossaryEnergy.NS_REFERENCE}, + 'solid_fuel_elec_percentage': {'type': 'float', 'default': 0.75, 'unit': '-', 'user_level': 2}, + 'solid_fuel_elec_constraint_ref': {'type': 'float', 'default': 10000., 'unit': 'Twh', 'user_level': 2,}, + 'liquid_hydrogen_percentage': {'type': 'array', 'user_level': 2, 'unit': '%',}, + 'liquid_hydrogen_constraint_ref': {'type': 'float', 'default': 1000., 'unit': 'Twh', 'user_level': 2,}, 'ref_constraint_non_use_capital_energy': {'type': 'float', 'default': 0.30, 'unit':'-','description': '0.30 means after 35 % of capital not used the constraint will explode'}, 'tol_constraint_non_use_capital_energy': {'type': 'float', 'default': 0.05, 'unit':'-','description': '0.05 means constraint does not penalize lagrangian when non use capital is less than 5%'}, 'period_tol_power_non_use_capital_constraint': {'type': 'float', 'default': 1.0, 'unit':'-','description': '0.05 means constraint does not penalize lagrangian when non use capital is less than 5%'}, - 'syngas_prod_ref': {'type': 'float', 'default': 10000., 'unit': 'TWh', 'user_level': 2, - 'visibility': SoSWrapp.SHARED_VISIBILITY, 'namespace': GlossaryEnergy.NS_REFERENCE}, - 'syngas_prod_constraint_limit': {'type': 'float', 'default': 10000., 'unit': 'TWh', 'user_level': 2, - 'visibility': SoSWrapp.SHARED_VISIBILITY, - 'namespace': GlossaryEnergy.NS_REFERENCE}, - - 'ratio_ref': {'type': 'float', 'default': 500., 'unit': '-', 'user_level': 2, - 'visibility': SoSWrapp.SHARED_VISIBILITY, 'namespace': GlossaryEnergy.NS_REFERENCE}, + 'syngas_prod_ref': {'type': 'float', 'default': 10000., 'unit': 'TWh', 'user_level': 2}, + 'syngas_prod_constraint_limit': {'type': 'float', 'default': 10000., 'unit': 'TWh', 'user_level': 2}, + 'ratio_ref': {'type': 'float', 'default': 500., 'unit': '-', 'user_level': 2}, 'heat_losses_percentage': {'type': 'float', 'default': heat_losses_percentage_default, 'unit': '%', 'range': [0., 100.]}, } @@ -252,12 +233,13 @@ def setup_sos_disciplines(self): inputs_dict = self.get_sosdisc_inputs() if GlossaryEnergy.YearStart in self.get_data_in(): year_start, year_end = self.get_sosdisc_inputs([GlossaryEnergy.YearStart, GlossaryEnergy.YearEnd]) - years = np.arange(year_start, year_end + 1) - default_target_energy_production = pd.DataFrame({GlossaryEnergy.Years: years, - GlossaryEnergy.TargetEnergyProductionValue: np.zeros_like( - years)}) - self.set_dynamic_default_values( - {GlossaryEnergy.TargetEnergyProductionValue: default_target_energy_production}) + if year_start is not None and year_end is not None: + years = np.arange(year_start, year_end + 1) + default_target_energy_production = pd.DataFrame({GlossaryEnergy.Years: years, + GlossaryEnergy.TargetEnergyProductionValue: np.zeros_like( + years)}) + self.set_dynamic_default_values( + {GlossaryEnergy.TargetEnergyProductionValue: default_target_energy_production}) if GlossaryEnergy.energy_list in self.get_data_in(): energy_list = inputs_dict[GlossaryEnergy.energy_list] if energy_list is not None: @@ -369,12 +351,14 @@ def update_default_with_years(self, inputs_dict): ''' Update default variables knowing the year start and the year end ''' - if GlossaryEnergy.YearStart in inputs_dict: - years = np.arange(inputs_dict[GlossaryEnergy.YearStart], inputs_dict[GlossaryEnergy.YearEnd] + 1) - lh_perc_default = np.concatenate( - (np.ones(5) * 1e-4, np.ones(len(years) - 5) / 4), axis=None) - self.set_dynamic_default_values( - {'liquid_hydrogen_percentage': lh_perc_default}) + if GlossaryEnergy.YearStart in self.get_data_in(): + year_start, year_end = self.get_sosdisc_inputs([GlossaryEnergy.YearStart, GlossaryEnergy.YearEnd]) + if year_start is not None and year_end is not None: + years = np.arange(year_start, year_end + 1) + lh_perc_default = np.concatenate( + (np.ones(5) * 1e-4, np.ones(len(years) - 5) / 4), axis=None) + self.set_dynamic_default_values( + {'liquid_hydrogen_percentage': lh_perc_default}) def run(self): # -- get inputs diff --git a/energy_models/core/energy_process_builder.py b/energy_models/core/energy_process_builder.py index 5e47c5ce..fb9c22e7 100644 --- a/energy_models/core/energy_process_builder.py +++ b/energy_models/core/energy_process_builder.py @@ -24,15 +24,15 @@ # Only one discipline with absolute values for # investments per techno and a constraint ] -INVEST_DISCIPLINE_DEFAULT = INVEST_DISCIPLINE_OPTIONS[1] # 'one_invest' +INVEST_DISCIPLINE_DEFAULT = INVEST_DISCIPLINE_OPTIONS[1] class EnergyProcessBuilder(BaseProcessBuilder): - def __init__(self, ee): + def __init__(self, ee, invest_discipline: str = INVEST_DISCIPLINE_DEFAULT): BaseProcessBuilder.__init__(self, ee) self.techno_list = None - self.invest_discipline = INVEST_DISCIPLINE_DEFAULT + self.invest_discipline = invest_discipline self.associate_namespace = False #self.energy_name = filename.split('\\')[-2].replace("_mix", '') #self.techno_list = current_techno_dict[self.energy_name] diff --git a/energy_models/core/stream_type/energy_disciplines/clean_energy_disc.py b/energy_models/core/stream_type/energy_disciplines/clean_energy_disc.py index 3ec0e37b..ea99a2ec 100644 --- a/energy_models/core/stream_type/energy_disciplines/clean_energy_disc.py +++ b/energy_models/core/stream_type/energy_disciplines/clean_energy_disc.py @@ -30,7 +30,7 @@ class CleanEnergyDiscipline(EnergyDiscipline): 'last_modification_date': '', 'category': '', 'definition': '', - 'icon': '', + 'icon': 'fas fa-fan fa-fw', 'version': '', } diff --git a/energy_models/core/stream_type/energy_disciplines/electricity_disc.py b/energy_models/core/stream_type/energy_disciplines/electricity_disc.py index 0f654b0e..284525b8 100644 --- a/energy_models/core/stream_type/energy_disciplines/electricity_disc.py +++ b/energy_models/core/stream_type/energy_disciplines/electricity_disc.py @@ -53,15 +53,11 @@ class ElectricityDiscipline(EnergyDiscipline): # 4400TWh is total production, # we use a 50% higher value 'unit': 'Twh', - 'user_level': 2, - 'visibility': SoSWrapp.SHARED_VISIBILITY, - 'namespace': GlossaryEnergy.NS_REFERENCE}, + 'user_level': 2,}, 'hydropower_constraint_ref': {'type': 'float', 'default': 1000., 'unit': 'Twh', - 'user_level': 2, - 'visibility': SoSWrapp.SHARED_VISIBILITY, - 'namespace': GlossaryEnergy.NS_REFERENCE}, + 'user_level': 2,}, 'data_fuel_dict': {'type': 'dict', 'visibility': EnergyDiscipline.SHARED_VISIBILITY, 'namespace': 'ns_electricity', diff --git a/energy_models/core/stream_type/energy_disciplines/fossil_disc.py b/energy_models/core/stream_type/energy_disciplines/fossil_disc.py index f9154d40..44594c68 100644 --- a/energy_models/core/stream_type/energy_disciplines/fossil_disc.py +++ b/energy_models/core/stream_type/energy_disciplines/fossil_disc.py @@ -30,7 +30,7 @@ class FossilDiscipline(EnergyDiscipline): 'last_modification_date': '', 'category': '', 'definition': '', - 'icon': '', + 'icon': 'fas fa-smog fa-fw', 'version': '', } diff --git a/energy_models/core/techno_type/disciplines/carbon_capture_techno_disc.py b/energy_models/core/techno_type/disciplines/carbon_capture_techno_disc.py index 40c564f7..d71723c4 100644 --- a/energy_models/core/techno_type/disciplines/carbon_capture_techno_disc.py +++ b/energy_models/core/techno_type/disciplines/carbon_capture_techno_disc.py @@ -219,6 +219,15 @@ def get_post_processing_list(self, filters=None): if new_chart is not None: instanciated_charts.append(new_chart) + if 'Power plants initial age distribution' in charts: + new_chart = self.get_chart_initial_age_distrib() + if new_chart is not None: + instanciated_charts.append(new_chart) + + if 'Capex' in charts: + new_chart = self.get_chart_capex() + instanciated_charts.append(new_chart) + return instanciated_charts def get_chart_detailed_price_in_dollar_tCO2(self): diff --git a/energy_models/core/techno_type/disciplines/carbon_storage_techno_disc.py b/energy_models/core/techno_type/disciplines/carbon_storage_techno_disc.py index 486f51a6..02704b57 100644 --- a/energy_models/core/techno_type/disciplines/carbon_storage_techno_disc.py +++ b/energy_models/core/techno_type/disciplines/carbon_storage_techno_disc.py @@ -125,6 +125,15 @@ def get_post_processing_list(self, filters=None): if new_chart is not None: instanciated_charts.append(new_chart) + if 'Power plants initial age distribution' in charts: + new_chart = self.get_chart_initial_age_distrib() + if new_chart is not None: + instanciated_charts.append(new_chart) + + if 'Capex' in charts: + new_chart = self.get_chart_capex() + instanciated_charts.append(new_chart) + return instanciated_charts def get_chart_detailed_price_in_dollar_ton(self): diff --git a/energy_models/core/techno_type/techno_disc.py b/energy_models/core/techno_type/techno_disc.py index db612c3b..9043dc60 100644 --- a/energy_models/core/techno_type/techno_disc.py +++ b/energy_models/core/techno_type/techno_disc.py @@ -180,30 +180,31 @@ def setup_sos_disciplines(self): if GlossaryEnergy.BoolApplyRatio in self.get_data_in(): year_start, year_end = self.get_sosdisc_inputs([GlossaryEnergy.YearStart, GlossaryEnergy.YearEnd]) - years = np.arange(year_start, year_end + 1) - if self.get_sosdisc_inputs(GlossaryEnergy.BoolApplyStreamRatio): - demand_ratio_dict = dict( - zip(EnergyMix.energy_list, np.linspace(1.0, 1.0, len(years)) * 100.0)) - demand_ratio_dict[GlossaryEnergy.Years] = years - all_streams_demand_ratio_default = pd.DataFrame( - demand_ratio_dict) - dynamic_inputs[GlossaryEnergy.AllStreamsDemandRatioValue] = {'type': 'dataframe', 'unit': '-', - 'default': all_streams_demand_ratio_default, - 'visibility': SoSWrapp.SHARED_VISIBILITY, - 'namespace': 'ns_energy', - "dynamic_dataframe_columns": True - } - if self.get_sosdisc_inputs(GlossaryEnergy.BoolApplyResourceRatio): - resource_ratio_dict = dict( - zip(EnergyMix.RESOURCE_LIST, np.ones(len(years)) * 100.0)) - resource_ratio_dict[GlossaryEnergy.Years] = years - all_resource_ratio_usable_demand_default = pd.DataFrame( - resource_ratio_dict) - dynamic_inputs[ResourceMixModel.RATIO_USABLE_DEMAND] = {'type': 'dataframe', 'unit': '-', - 'default': all_resource_ratio_usable_demand_default, - 'visibility': SoSWrapp.SHARED_VISIBILITY, - 'namespace': 'ns_resource', - "dynamic_dataframe_columns": True} + if year_start is not None and year_end is not None: + years = np.arange(year_start, year_end + 1) + if self.get_sosdisc_inputs(GlossaryEnergy.BoolApplyStreamRatio): + demand_ratio_dict = dict( + zip(EnergyMix.energy_list, np.linspace(1.0, 1.0, len(years)) * 100.0)) + demand_ratio_dict[GlossaryEnergy.Years] = years + all_streams_demand_ratio_default = pd.DataFrame( + demand_ratio_dict) + dynamic_inputs[GlossaryEnergy.AllStreamsDemandRatioValue] = {'type': 'dataframe', 'unit': '-', + 'default': all_streams_demand_ratio_default, + 'visibility': SoSWrapp.SHARED_VISIBILITY, + 'namespace': 'ns_energy', + "dynamic_dataframe_columns": True + } + if self.get_sosdisc_inputs(GlossaryEnergy.BoolApplyResourceRatio): + resource_ratio_dict = dict( + zip(EnergyMix.RESOURCE_LIST, np.ones(len(years)) * 100.0)) + resource_ratio_dict[GlossaryEnergy.Years] = years + all_resource_ratio_usable_demand_default = pd.DataFrame( + resource_ratio_dict) + dynamic_inputs[ResourceMixModel.RATIO_USABLE_DEMAND] = {'type': 'dataframe', 'unit': '-', + 'default': all_resource_ratio_usable_demand_default, + 'visibility': SoSWrapp.SHARED_VISIBILITY, + 'namespace': 'ns_resource', + "dynamic_dataframe_columns": True} dynamic_outputs.update({ GlossaryEnergy.TechnoPricesValue: GlossaryEnergy.get_techno_price_df(techno_name=self.techno_name), @@ -238,29 +239,24 @@ def update_default_values(self): if GlossaryEnergy.InitialPlantsAgeDistribFactor in self.get_data_in() and GlossaryEnergy.YearStart in self.get_data_in(): year_start = self.get_sosdisc_inputs(GlossaryEnergy.YearStart) - initial_plant_age_distrib_factor = self.get_sosdisc_inputs(GlossaryEnergy.InitialPlantsAgeDistribFactor) - if initial_plant_age_distrib_factor is None and year_start is not None: + if year_start is not None: initial_plant_age_distrib_factor, _ = DatabaseWitnessEnergy.get_techno_age_distrib_factor(self.techno_name, year=year_start) self.update_default_value(GlossaryEnergy.InitialPlantsAgeDistribFactor, 'in', initial_plant_age_distrib_factor) if 'initial_production' in self.get_data_in() and GlossaryEnergy.YearStart in self.get_data_in(): year_start = self.get_sosdisc_inputs(GlossaryEnergy.YearStart) - initial_production = self.get_sosdisc_inputs('initial_production') - if initial_production is None and year_start is not None: + if year_start is not None: initial_production, _ = DatabaseWitnessEnergy.get_techno_prod(self.techno_name, year=year_start) self.update_default_value('initial_production', 'in', initial_production) construction_delay = None if GlossaryEnergy.ConstructionDelay in self.get_data_in(): - construction_delay = self.get_sosdisc_inputs(GlossaryEnergy.ConstructionDelay) - if construction_delay is None: - construction_delay = GlossaryEnergy.TechnoConstructionDelayDict[self.techno_name] - self.update_default_value(GlossaryEnergy.ConstructionDelay, 'in', construction_delay) + construction_delay = GlossaryEnergy.TechnoConstructionDelayDict[self.techno_name] + self.update_default_value(GlossaryEnergy.ConstructionDelay, 'in', construction_delay) if GlossaryEnergy.InvestmentBeforeYearStartValue in self.get_data_in() and GlossaryEnergy.YearStart in self.get_data_in() and 'techno_infos_dict' in self.get_data_in(): year_start = self.get_sosdisc_inputs(GlossaryEnergy.YearStart) - invest_before_year_start_val = self.get_sosdisc_inputs(GlossaryEnergy.InvestmentBeforeYearStartValue) - if year_start is not None and construction_delay is not None and invest_before_year_start_val is None: + if year_start is not None and construction_delay is not None: default_val, _ = DatabaseWitnessEnergy.get_techno_invest_before_year_start( techno_name=self.techno_name, year_start=year_start, construction_delay=construction_delay) self.update_default_value(GlossaryEnergy.InvestmentBeforeYearStartValue, 'in', default_val) @@ -749,7 +745,9 @@ def get_chart_filter_list(self): 'CO2 emissions', GlossaryEnergy.UtilisationRatioValue, 'Non-Use Capital', - 'Power production'] + 'Power production', + 'Power plants initial age distribution', + 'Capex'] if self.get_sosdisc_inputs(GlossaryEnergy.BoolApplyRatio): chart_list.extend(['Applied Ratio']) chart_filters.append(ChartFilter( @@ -841,6 +839,15 @@ def get_post_processing_list(self, filters=None): new_chart = self.get_chart_power_production(technos_info_dict) if new_chart is not None: instanciated_charts.append(new_chart) + if 'Power plants initial age distribution' in charts: + new_chart = self.get_chart_initial_age_distrib() + if new_chart is not None: + instanciated_charts.append(new_chart) + + if 'Capex' in charts: + new_chart = self.get_chart_capex() + instanciated_charts.append(new_chart) + return instanciated_charts def get_utilisation_ratio_chart(self): @@ -1366,3 +1373,27 @@ def get_chart_power_production(self, technos_info_dict): new_chart.series.append(serie) return new_chart + + def get_chart_initial_age_distrib(self): + age_distrib = self.get_sosdisc_outputs('initial_age_distrib') + chart_name = 'Age distribution of initial power plants / factories' + + new_chart = TwoAxesInstanciatedChart('Age', '%', chart_name=chart_name) + + serie = InstanciatedSeries( + age_distrib['age'].values.tolist(), + age_distrib['distrib'].values.tolist(), '', 'bar') + + new_chart.series.append(serie) + return new_chart + + def get_chart_capex(self): + cost_details = self.get_sosdisc_outputs(GlossaryEnergy.TechnoDetailedPricesValue) + chart_name = 'Capex' + years = cost_details[GlossaryEnergy.Years] + capex = cost_details[f'Capex_{self.techno_name}'] + new_chart = TwoAxesInstanciatedChart(GlossaryEnergy.Years, '$/MWh', chart_name=chart_name) + serie = InstanciatedSeries( years, capex, '','lines') + + new_chart.series.append(serie) + return new_chart diff --git a/energy_models/database_witness_energy.py b/energy_models/database_witness_energy.py index 5176ec29..94663df4 100644 --- a/energy_models/database_witness_energy.py +++ b/energy_models/database_witness_energy.py @@ -105,7 +105,12 @@ def get_techno_invest_before_year_start(cls, techno_name: str, year_start: int, out_df = df.loc[df['years'] < year_start] if is_available_at_year: return construction_delay == 0 or (heavy_collected_data.is_available_at_year(year_start - construction_delay) and heavy_collected_data.is_available_at_year(year_start - 1)) - if construction_delay > 0: + if construction_delay == 0: + out_df = pd.DataFrame({ + "years": [], + "invest": [] + }) + elif construction_delay > 0: out_df = heavy_collected_data.get_between_years(year_start=year_start - construction_delay, year_end=year_start - 1) return out_df, heavy_collected_data diff --git a/energy_models/models/carbon_capture/direct_air_capture/direct_air_capture_techno/direct_air_capture_techno_disc.py b/energy_models/models/carbon_capture/direct_air_capture/direct_air_capture_techno/direct_air_capture_techno_disc.py index 9de85293..a1cdcf9d 100644 --- a/energy_models/models/carbon_capture/direct_air_capture/direct_air_capture_techno/direct_air_capture_techno_disc.py +++ b/energy_models/models/carbon_capture/direct_air_capture/direct_air_capture_techno/direct_air_capture_techno_disc.py @@ -41,7 +41,7 @@ class DirectAirCaptureTechnoDiscipline(CCTechnoDiscipline): 'last_modification_date': '', 'category': '', 'definition': '', - 'icon': 'fa-solid fa-globe-europe fa-fw', + 'icon': 'fas fa-air-freshener fa-fw', 'version': '', } techno_name = f'{GlossaryEnergy.direct_air_capture}.{GlossaryEnergy.DirectAirCaptureTechno}' diff --git a/energy_models/models/carbon_storage/pure_carbon_solid_storage/pure_carbon_solid_storage_disc.py b/energy_models/models/carbon_storage/pure_carbon_solid_storage/pure_carbon_solid_storage_disc.py index 35c37b16..05ecfcf2 100644 --- a/energy_models/models/carbon_storage/pure_carbon_solid_storage/pure_carbon_solid_storage_disc.py +++ b/energy_models/models/carbon_storage/pure_carbon_solid_storage/pure_carbon_solid_storage_disc.py @@ -112,14 +112,15 @@ def setup_sos_disciplines(self): if self.get_data_in() is not None: if GlossaryEnergy.YearStart in self.get_data_in(): year_start, year_end = self.get_sosdisc_inputs([GlossaryEnergy.YearStart, GlossaryEnergy.YearEnd]) - years = np.arange(year_start, year_end + 1) - - if self.get_sosdisc_inputs('carbon_quantity_to_be_stored') is not None: - if self.get_sosdisc_inputs('carbon_quantity_to_be_stored')[ - GlossaryEnergy.Years].values.tolist() != list(years): - self.update_default_value( - 'carbon_quantity_to_be_stored', self.IO_TYPE_IN, - pd.DataFrame({GlossaryEnergy.Years: years, GlossaryEnergy.carbon_storage: 0.})) + if year_start is not None and year_end is not None: + years = np.arange(year_start, year_end + 1) + + if self.get_sosdisc_inputs('carbon_quantity_to_be_stored') is not None: + if self.get_sosdisc_inputs('carbon_quantity_to_be_stored')[ + GlossaryEnergy.Years].values.tolist() != list(years): + self.update_default_value( + 'carbon_quantity_to_be_stored', self.IO_TYPE_IN, + pd.DataFrame({GlossaryEnergy.Years: years, GlossaryEnergy.carbon_storage: 0.})) def init_execution(self): inputs_dict = self.get_sosdisc_inputs() diff --git a/energy_models/models/gaseous_hydrogen/plasma_cracking/plasma_cracking_disc.py b/energy_models/models/gaseous_hydrogen/plasma_cracking/plasma_cracking_disc.py index 4ecdb673..054aaed6 100644 --- a/energy_models/models/gaseous_hydrogen/plasma_cracking/plasma_cracking_disc.py +++ b/energy_models/models/gaseous_hydrogen/plasma_cracking/plasma_cracking_disc.py @@ -110,16 +110,17 @@ def setup_sos_disciplines(self): if self.get_data_in() is not None: if GlossaryEnergy.YearStart in self.get_data_in(): year_start, year_end = self.get_sosdisc_inputs([GlossaryEnergy.YearStart, GlossaryEnergy.YearEnd]) - years = np.arange(year_start, year_end + 1) + if year_start is not None and year_end is not None: + years = np.arange(year_start, year_end + 1) - if self.get_sosdisc_inputs('CO2_credits')[GlossaryEnergy.Years].values.tolist() != list(years): - self.update_default_value( - 'CO2_credits', self.IO_TYPE_IN, pd.DataFrame({GlossaryEnergy.Years: years, 'CO2_credits': 50.})) + if self.get_sosdisc_inputs('CO2_credits')[GlossaryEnergy.Years].values.tolist() != list(years): + self.update_default_value( + 'CO2_credits', self.IO_TYPE_IN, pd.DataFrame({GlossaryEnergy.Years: years, 'CO2_credits': 50.})) - if self.get_sosdisc_inputs('market_demand')[GlossaryEnergy.Years].values.tolist() != list(years): - self.update_default_value( - 'market_demand', self.IO_TYPE_IN, - pd.DataFrame({GlossaryEnergy.Years: years, 'carbon_demand': 5e-2})) + if self.get_sosdisc_inputs('market_demand')[GlossaryEnergy.Years].values.tolist() != list(years): + self.update_default_value( + 'market_demand', self.IO_TYPE_IN, + pd.DataFrame({GlossaryEnergy.Years: years, 'carbon_demand': 5e-2})) def init_execution(self): inputs_dict = self.get_sosdisc_inputs() diff --git a/energy_models/sos_processes/energy/MDA/energy_mix_optim_sub_process/process.py b/energy_models/sos_processes/energy/MDA/energy_mix_optim_sub_process/process.py index ca47d9f1..26b4fc39 100644 --- a/energy_models/sos_processes/energy/MDA/energy_mix_optim_sub_process/process.py +++ b/energy_models/sos_processes/energy/MDA/energy_mix_optim_sub_process/process.py @@ -108,7 +108,6 @@ def get_builders(self): GlossaryEnergy.NS_ENERGY_MIX: f'{ns_study}.{coupling_name}.{energy_mix}', 'ns_carb': f'{ns_study}.{coupling_name}.{GlossaryEnergy.ccus_type}.{carbon_storage}.PureCarbonSolidStorage', 'ns_resource': f'{ns_study}', - GlossaryEnergy.NS_REFERENCE: f'{ns_study}.NormalizationReferences', 'ns_invest': f'{self.ee.study_name}.InvestmentDistribution', } @@ -122,7 +121,6 @@ def get_builders(self): GlossaryEnergy.NS_ENERGY_MIX: f'{ns_study}.{coupling_name}.{energy_mix}', 'ns_carb': f'{ns_study}.{coupling_name}.{GlossaryEnergy.ccus_type}.{carbon_storage}.PureCarbonSolidStorage', 'ns_resource': f'{ns_study}', - GlossaryEnergy.NS_REFERENCE: f'{ns_study}.NormalizationReferences', 'ns_invest': f'{self.ee.study_name}.InvestmentDistribution', GlossaryEnergy.NS_GHGEMISSIONS: f'{self.ee.study_name}.{coupling_name}.{GHGemissionsDiscipline.name}', } @@ -158,7 +156,6 @@ def get_builders(self): 'ns_energy': f'{ns_study}', GlossaryEnergy.NS_WITNESS: f'{ns_study}.{coupling_name}', GlossaryEnergy.NS_CCS: f'{ns_study}.{coupling_name}.{GlossaryEnergy.ccus_type}', - GlossaryEnergy.NS_REFERENCE: f'{ns_study}.{energy_mix}.{carbon_storage}.NormalizationReferences', GlossaryEnergy.NS_FUNCTIONS: f'{self.ee.study_name}.{coupling_name}.{func_manager_name}', 'ns_forest': f"{ns_study}.{coupling_name}.{INVEST_DISC_NAME}", 'ns_crop': f"{ns_study}.{coupling_name}.{INVEST_DISC_NAME}", @@ -197,7 +194,6 @@ def get_builders(self): 'ns_emissions': f'{ns_study}.{energy_mix}', 'ns_land_use': f'{self.ee.study_name}.EnergyMix', GlossaryEnergy.NS_FUNCTIONS: f'{self.ee.study_name}.{coupling_name}.{func_manager_name}', - GlossaryEnergy.NS_REFERENCE: f'{self.ee.study_name}.NormalizationReferences', 'ns_invest': f'{self.ee.study_name}.{coupling_name}.{INVEST_DISC_NAME}'} self.ee.ns_manager.add_ns_def(ns_dict) @@ -219,7 +215,6 @@ def get_builders(self): ns_dict = {GlossaryEnergy.NS_FUNCTIONS: f'{self.ee.study_name}.{coupling_name}.{func_manager_name}', 'ns_public': f'{self.ee.study_name}', 'ns_optim': f'{self.ee.study_name}', - GlossaryEnergy.NS_REFERENCE: f'{self.ee.study_name}.NormalizationReferences', 'ns_invest': f'{self.ee.study_name}.{coupling_name}.{INVEST_DISC_NAME}', } self.ee.ns_manager.add_ns_def(ns_dict) diff --git a/energy_models/sos_processes/energy/MDA/energy_process_v0/process.py b/energy_models/sos_processes/energy/MDA/energy_process_v0/process.py index 1f2a1fff..a17e8057 100644 --- a/energy_models/sos_processes/energy/MDA/energy_process_v0/process.py +++ b/energy_models/sos_processes/energy/MDA/energy_process_v0/process.py @@ -82,7 +82,6 @@ def get_builders(self): GlossaryEnergy.NS_ENERGY_MIX: f'{ns_study}.{energy_mix}', 'ns_carb': f'{ns_study}.{energy_mix}.{carbon_storage}.PureCarbonSolidStorage', 'ns_resource': f'{ns_study}.{energy_mix}.resource', - GlossaryEnergy.NS_REFERENCE: f'{ns_study}.NormalizationReferences', 'ns_invest': f'{self.ee.study_name}.InvestmentDistribution', } @@ -133,7 +132,6 @@ def get_builders(self): 'ns_energy': f'{ns_study}', GlossaryEnergy.NS_WITNESS: f'{ns_study}', GlossaryEnergy.NS_CCS: f'{ns_study}', - GlossaryEnergy.NS_REFERENCE: f'{ns_study}.{energy_mix}.{carbon_storage}.NormalizationReferences', GlossaryEnergy.NS_FUNCTIONS: f'{ns_study}.{func_manager_name}', } if not self.energy_invest_input_in_abs_value: diff --git a/energy_models/sos_processes/energy/MDA/energy_process_v0/usecase.py b/energy_models/sos_processes/energy/MDA/energy_process_v0/usecase.py index e5418428..38b05f09 100644 --- a/energy_models/sos_processes/energy/MDA/energy_process_v0/usecase.py +++ b/energy_models/sos_processes/energy/MDA/energy_process_v0/usecase.py @@ -93,8 +93,8 @@ def __init__( self.dict_technos = {} if invest_discipline == INVEST_DISCIPLINE_OPTIONS[2]: - self.lower_bound_techno = 1.0e-6 - self.upper_bound_techno = 3000 + self.lower_bound_techno = 5. + self.upper_bound_techno = 8000 else: self.lower_bound_techno = lower_bound_techno diff --git a/energy_models/sos_processes/energy/MDA/energy_process_v0_mda/process.py b/energy_models/sos_processes/energy/MDA/energy_process_v0_mda/process.py index 4193ad22..ef5fa2c6 100644 --- a/energy_models/sos_processes/energy/MDA/energy_process_v0_mda/process.py +++ b/energy_models/sos_processes/energy/MDA/energy_process_v0_mda/process.py @@ -55,8 +55,7 @@ def get_builders(self): ns_dict = {'ns_energy': f'{ns_study}.{energy_mix}', 'ns_carb': f'{ns_study}.{ccs_mix}.{carbon_storage}.PureCarbonSolidStorage', - GlossaryEnergy.NS_REFERENCE: f'{ns_study}.NormalizationReferences', - 'ns_emissions': f'{ns_study}.{energy_mix}', } + 'ns_emissions': f'{ns_study}.{energy_mix}', } self.ee.ns_manager.add_ns_def(ns_dict) diff --git a/energy_models/sos_processes/energy/techno_mix/clean_energy_mix/process.py b/energy_models/sos_processes/energy/techno_mix/clean_energy_mix/process.py index 8ed3aa90..0506073a 100644 --- a/energy_models/sos_processes/energy/techno_mix/clean_energy_mix/process.py +++ b/energy_models/sos_processes/energy/techno_mix/clean_energy_mix/process.py @@ -42,7 +42,6 @@ def get_builders(self): 'ns_energy_study': f'{ns_study}', 'ns_public': f'{ns_study}', GlossaryEnergy.NS_FUNCTIONS: f'{ns_study}', - GlossaryEnergy.NS_REFERENCE: f'{ns_study}', 'ns_resource': f'{ns_study}.{energy_mix}'} mods_dict = {} mods_dict[f'{energy_mix}.{CleanEnergy.name}'] = self.get_stream_disc_path( diff --git a/energy_models/sos_processes/energy/techno_mix/electricity_mix/process.py b/energy_models/sos_processes/energy/techno_mix/electricity_mix/process.py index 55aaaa24..cfce6fac 100644 --- a/energy_models/sos_processes/energy/techno_mix/electricity_mix/process.py +++ b/energy_models/sos_processes/energy/techno_mix/electricity_mix/process.py @@ -49,7 +49,6 @@ def get_builders(self): 'ns_energy_study': f'{ns_study}', 'ns_public': f'{ns_study}', GlossaryEnergy.NS_FUNCTIONS: f'{ns_study}', - GlossaryEnergy.NS_REFERENCE: f'{ns_study}', 'ns_resource': f'{ns_study}.{energy_mix}'} mods_dict = {} mods_dict[f'{energy_mix}.{electricity_name}'] = self.get_stream_disc_path( diff --git a/energy_models/sos_processes/energy/techno_mix/fossil_mix/process.py b/energy_models/sos_processes/energy/techno_mix/fossil_mix/process.py index a405bbb2..62d0cbb3 100644 --- a/energy_models/sos_processes/energy/techno_mix/fossil_mix/process.py +++ b/energy_models/sos_processes/energy/techno_mix/fossil_mix/process.py @@ -43,7 +43,6 @@ def get_builders(self): 'ns_energy_study': f'{ns_study}', 'ns_public': f'{ns_study}', GlossaryEnergy.NS_FUNCTIONS: f'{ns_study}', - GlossaryEnergy.NS_REFERENCE: f'{ns_study}', 'ns_resource': f'{ns_study}.{energy_mix}'} mods_dict = {} mods_dict[f'{energy_mix}.{fossil_name}'] = self.get_stream_disc_path( diff --git a/energy_models/tests/jacobian_pkls/jacobian_FossilSimpleTechno_FossilSimpleTechno_construction_delay_0.pkl b/energy_models/tests/jacobian_pkls/jacobian_FossilSimpleTechno_FossilSimpleTechno_construction_delay_0.pkl index e7bb96bb..e4808406 100644 Binary files a/energy_models/tests/jacobian_pkls/jacobian_FossilSimpleTechno_FossilSimpleTechno_construction_delay_0.pkl and b/energy_models/tests/jacobian_pkls/jacobian_FossilSimpleTechno_FossilSimpleTechno_construction_delay_0.pkl differ diff --git a/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc.pkl b/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc.pkl deleted file mode 100644 index 28fcb121..00000000 Binary files a/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc.pkl and /dev/null differ diff --git a/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc_all_years.pkl b/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc_all_years.pkl deleted file mode 100644 index cbfa9a0a..00000000 Binary files a/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc_all_years.pkl and /dev/null differ diff --git a/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc_mix.pkl b/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc_mix.pkl deleted file mode 100644 index 9f385a30..00000000 Binary files a/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc_mix.pkl and /dev/null differ diff --git a/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc_poles.pkl b/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc_poles.pkl deleted file mode 100644 index e823eaeb..00000000 Binary files a/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc_poles.pkl and /dev/null differ diff --git a/energy_models/tests/jacobian_pkls/jacobian_ratio_FossilGas.pkl b/energy_models/tests/jacobian_pkls/jacobian_ratio_FossilGas.pkl index 1ad0751e..fdfa1b8f 100644 Binary files a/energy_models/tests/jacobian_pkls/jacobian_ratio_FossilGas.pkl and b/energy_models/tests/jacobian_pkls/jacobian_ratio_FossilGas.pkl differ diff --git a/energy_models/tests/l0_test_compute_ccus_disc.py b/energy_models/tests/l0_test_compute_ccus_disc.py index 602ed5ac..90f227e7 100644 --- a/energy_models/tests/l0_test_compute_ccus_disc.py +++ b/energy_models/tests/l0_test_compute_ccus_disc.py @@ -96,7 +96,6 @@ def test_01_CCUS_discipline(self): 'ns_energy': self.name, GlossaryEnergy.NS_CCS: self.name, 'ns_energy_study': self.name, - GlossaryEnergy.NS_REFERENCE: self.name, GlossaryEnergy.NS_FUNCTIONS: self.name, 'ns_carbon_capture': self.name, 'ns_carbon_storage': self.name} diff --git a/energy_models/tests/l0_test_compute_demand.py b/energy_models/tests/l0_test_compute_demand.py index 0979e260..f54d279d 100644 --- a/energy_models/tests/l0_test_compute_demand.py +++ b/energy_models/tests/l0_test_compute_demand.py @@ -53,7 +53,6 @@ def test_01_demand_discipline(self): self.model_name = 'Demand' self.ee = ExecutionEngine(self.name) ns_dict = {'ns_public': f'{self.name}', - GlossaryEnergy.NS_REFERENCE: f'{self.name}', GlossaryEnergy.NS_FUNCTIONS: f'{self.name}.{self.model_name}', GlossaryEnergy.NS_ENERGY_MIX: f'{self.name}', GlossaryEnergy.NS_WITNESS: f'{self.name}'} diff --git a/energy_models/tests/l0_test_compute_energy_mix.py b/energy_models/tests/l0_test_compute_energy_mix.py index cf4f4493..09112800 100644 --- a/energy_models/tests/l0_test_compute_energy_mix.py +++ b/energy_models/tests/l0_test_compute_energy_mix.py @@ -152,7 +152,6 @@ def test_02_energy_mix_discipline(self): GlossaryEnergy.NS_FUNCTIONS: f'{name}.{model_name}', 'ns_resource': f'{name}.{model_name}.resource', GlossaryEnergy.NS_CCS: f'{name}.{model_name}', - GlossaryEnergy.NS_REFERENCE: f'{name}.{model_name}', 'ns_energy': f'{name}.{model_name}', GlossaryEnergy.NS_WITNESS: f'{name}'} ee.ns_manager.add_ns_def(ns_dict) @@ -246,7 +245,6 @@ def test_03_energy_mix_discipline_exponential_limit(self): GlossaryEnergy.NS_FUNCTIONS: f'{name}.{model_name}', 'ns_resource': f'{name}.{model_name}.resource', GlossaryEnergy.NS_CCS: f'{name}.{model_name}', - GlossaryEnergy.NS_REFERENCE: f'{name}.{model_name}', 'ns_energy': f'{name}.{model_name}'} ee.ns_manager.add_ns_def(ns_dict) @@ -330,7 +328,6 @@ def test_04_energy_mix_resource(self): GlossaryEnergy.NS_FUNCTIONS: f'{name}.{model_name}', 'ns_resource': f'{name}.{model_name}.resource', GlossaryEnergy.NS_CCS: f'{name}.{model_name}', - GlossaryEnergy.NS_REFERENCE: f'{name}.{model_name}', 'ns_energy': f'{name}.{model_name}'} ee.ns_manager.add_ns_def(ns_dict) diff --git a/energy_models/tests/l0_test_energy_invest_redistribution.py b/energy_models/tests/l0_test_energy_invest_redistribution.py index e8ac669c..cb0b5d76 100644 --- a/energy_models/tests/l0_test_energy_invest_redistribution.py +++ b/energy_models/tests/l0_test_energy_invest_redistribution.py @@ -88,7 +88,6 @@ def test_01_redistribution_invest_disc(self): self.model_name = 'Invest' self.ee = ExecutionEngine(self.name) ns_dict = {GlossaryEnergy.NS_WITNESS: self.name, - GlossaryEnergy.NS_REFERENCE: self.name, 'ns_public': self.name, 'ns_energy_study': self.name, GlossaryEnergy.NS_CCS: f'{self.name}.CCUS', @@ -162,7 +161,6 @@ def test_02_redistribution_invest_disc_gradient(self): self.model_name = 'Invest' self.ee = ExecutionEngine(self.name) ns_dict = {GlossaryEnergy.NS_WITNESS: self.name, - GlossaryEnergy.NS_REFERENCE: self.name, 'ns_public': self.name, 'ns_energy_study': self.name, GlossaryEnergy.NS_CCS: f'{self.name}', @@ -220,7 +218,6 @@ def test_02_redistribution_invest_disc_gradient_wih_biomass_dry(self): self.model_name = 'Invest' self.ee = ExecutionEngine(self.name) ns_dict = {GlossaryEnergy.NS_WITNESS: self.name, - GlossaryEnergy.NS_REFERENCE: self.name, 'ns_public': self.name, 'ns_energy_study': self.name, GlossaryEnergy.NS_CCS: f'{self.name}', diff --git a/energy_models/tests/l0_test_independent_invest.py b/energy_models/tests/l0_test_independent_invest.py index c9099d97..cc8ecba2 100644 --- a/energy_models/tests/l0_test_independent_invest.py +++ b/energy_models/tests/l0_test_independent_invest.py @@ -89,7 +89,6 @@ def test_02_independent_invest_disc(self): self.model_name = 'Invest' self.ee = ExecutionEngine(self.name) ns_dict = {GlossaryEnergy.NS_WITNESS: self.name, - GlossaryEnergy.NS_REFERENCE: self.name, 'ns_public': self.name, 'ns_energy_study': self.name, GlossaryEnergy.NS_CCS: f'{self.name}.CCUS', @@ -159,7 +158,6 @@ def test_03_independent_invest_with_forest_disc(self): self.model_name = 'Invest' self.ee = ExecutionEngine(self.name) ns_dict = {GlossaryEnergy.NS_WITNESS: self.name, - GlossaryEnergy.NS_REFERENCE: self.name, 'ns_public': self.name, 'ns_energy_study': self.name, GlossaryEnergy.NS_CCS: f'{self.name}.CCUS', diff --git a/energy_models/tests/l1_test_base_stream_electricity.py b/energy_models/tests/l1_test_base_stream_electricity.py index 32b64f20..82ddb7ed 100644 --- a/energy_models/tests/l1_test_base_stream_electricity.py +++ b/energy_models/tests/l1_test_base_stream_electricity.py @@ -105,8 +105,7 @@ def test_01_base_stream(self): 'ns_electricity': f'{self.name}', 'ns_energy_study': f'{self.name}', GlossaryEnergy.NS_FUNCTIONS: f'{self.name}', - GlossaryEnergy.NS_ENERGY_MIX: self.name, - GlossaryEnergy.NS_REFERENCE: self.name} + GlossaryEnergy.NS_ENERGY_MIX: self.name,} self.ee.ns_manager.add_ns_def(ns_dict) mod_path = 'energy_models.core.stream_type.energy_disciplines.electricity_disc.ElectricityDiscipline' diff --git a/energy_models/tests/l1_test_gradient_ccus_disc.py b/energy_models/tests/l1_test_gradient_ccus_disc.py index 911f76c1..1bca56be 100644 --- a/energy_models/tests/l1_test_gradient_ccus_disc.py +++ b/energy_models/tests/l1_test_gradient_ccus_disc.py @@ -121,7 +121,6 @@ def test_01_Consumption_ccus_disciplinejacobian(self): 'ns_energy': self.name, GlossaryEnergy.NS_CCS: self.name, 'ns_energy_study': self.name, - GlossaryEnergy.NS_REFERENCE: self.name, GlossaryEnergy.NS_FUNCTIONS: self.name, 'ns_carbon_capture': self.name, 'ns_carbon_storage': self.name} diff --git a/energy_models/tests/l1_test_gradient_demand_model.py b/energy_models/tests/l1_test_gradient_demand_model.py index 121b1225..05e7bf82 100644 --- a/energy_models/tests/l1_test_gradient_demand_model.py +++ b/energy_models/tests/l1_test_gradient_demand_model.py @@ -77,7 +77,6 @@ def test_01_demand_model_discipline_jacobian(self): self.model_name = 'demand_model' self.ee = ExecutionEngine(self.name) ns_dict = {'ns_public': f'{self.name}', - GlossaryEnergy.NS_REFERENCE: f'{self.name}', GlossaryEnergy.NS_FUNCTIONS: f'{self.name}.{self.model_name}', GlossaryEnergy.NS_ENERGY_MIX: f'{self.name}', GlossaryEnergy.NS_WITNESS: f'{self.name}'} diff --git a/energy_models/tests/l1_test_gradient_electricity.py b/energy_models/tests/l1_test_gradient_electricity.py index 231711b4..283a6bd6 100644 --- a/energy_models/tests/l1_test_gradient_electricity.py +++ b/energy_models/tests/l1_test_gradient_electricity.py @@ -925,7 +925,6 @@ def test_14_electricity_discipline_jacobian(self): self.ee = ExecutionEngine(self.name) ns_dict = {'ns_public': f'{self.name}', 'ns_electricity': f'{self.name}', - GlossaryEnergy.NS_REFERENCE: f'{self.name}', GlossaryEnergy.NS_FUNCTIONS: f'{self.name}', 'ns_energy_study': f'{self.name}', 'ns_resource': f'{self.name}'} diff --git a/energy_models/tests/l1_test_gradient_investments_profile_builder.py b/energy_models/tests/l1_test_gradient_investments_profile_builder.py deleted file mode 100644 index 450104c8..00000000 --- a/energy_models/tests/l1_test_gradient_investments_profile_builder.py +++ /dev/null @@ -1,150 +0,0 @@ -''' -Copyright 2024 Capgemini - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -''' -from os.path import dirname - -import numpy as np -import pandas as pd -from sostrades_core.execution_engine.execution_engine import ExecutionEngine -from sostrades_core.tests.core.abstract_jacobian_unit_test import ( - AbstractJacobianUnittest, -) - -from energy_models.glossaryenergy import GlossaryEnergy - - -class TestInvestmentProfileBuilderDisc(AbstractJacobianUnittest): - """ - Resources prices test class - """ - - def setUp(self): - ''' - Initialize third data needed for testing - ''' - self.override_dump_jacobian = True # let that to True - self.name = 'Test' - self.model_name = 'investments profile' - self.columns_names = [GlossaryEnergy.clean_energy, GlossaryEnergy.fossil, GlossaryEnergy.carbon_capture] - self.n_profiles = 4 - self.coeff_jacobian = [f'{self.name}.{self.model_name}.coeff_{i}' for i in range(self.n_profiles)] - self.year_min = 2020 - self.year_max = 2025 - self.years = np.arange(self.year_min, self.year_max + 1) - - self.inputs_dict = { - f'{self.name}.{self.model_name}.column_names': self.columns_names, - f'{self.name}.{self.model_name}.n_profiles': self.n_profiles, - f'{self.name}.{self.model_name}.{GlossaryEnergy.EXPORT_PROFILES_AT_POLES}': False, - - } - - def df_generator(years): - df = pd.DataFrame({ - **{GlossaryEnergy.Years: years}, - **dict(zip(self.columns_names, np.random.rand(len(self.columns_names)))) - }) - return df - - self.inputs_dict.update({ - f"{self.name}.{self.model_name}.coeff_{i}": np.random.uniform(0, 15) for i in range(self.n_profiles) - }) - - self.inputs_dict.update({ - f"{self.name}.{self.model_name}.df_{i}": df_generator(self.years) for i in range(self.n_profiles) - }) - pass - - def tearDown(self): - pass - - def analytic_grad_entry(self): - return [ - self.test_01_output_invest_mix, - self.test_02_output_at_poles, - ] - - def test_01_output_invest_mix(self): - ''' - Test the gradient of the invest profile exported into invest_mix - ''' - - self.ee = ExecutionEngine(self.name) - ns_dict = {'ns_invest': f'{self.name}.{self.model_name}', } - self.ee.ns_manager.add_ns_def(ns_dict) - - mod_path = 'energy_models.core.investments.disciplines.investments_profile_builder_disc.InvestmentsProfileBuilderDisc' - - builder = self.ee.factory.get_builder_from_module( - self.model_name, mod_path) - - self.ee.factory.set_builders_to_coupling_builder(builder) - - self.ee.configure() - self.ee.display_treeview_nodes() - - self.ee.load_study_from_input_dict(self.inputs_dict) - - self.ee.execute() - - disc = self.ee.root_process.proxy_disciplines[0].mdo_discipline_wrapp.mdo_discipline - self.check_jacobian(derr_approx='complex_step', - inputs=self.coeff_jacobian, - outputs=[f'{self.name}.{self.model_name}.{GlossaryEnergy.invest_mix}'], - local_data=disc.local_data, - location=dirname(__file__), - discipline=disc, - filename='jacobian_investments_profile_builder_disc_all_years.pkl', threshold=1e-5, ) - - def test_02_output_at_poles(self): - ''' - Test the gradient of the invest profile exported into mix_array at the poles - ''' - inputs_dict = self.inputs_dict.copy() - nb_poles = 3 - inputs_dict.update({ - f'{self.name}.{self.model_name}.nb_poles': nb_poles, - f'{self.name}.{self.model_name}.{GlossaryEnergy.EXPORT_PROFILES_AT_POLES}': True, - - }) - - self.ee = ExecutionEngine(self.name) - ns_dict = {'ns_invest': f'{self.name}.{self.model_name}', } - self.ee.ns_manager.add_ns_def(ns_dict) - - mod_path = 'energy_models.core.investments.disciplines.investments_profile_builder_disc.InvestmentsProfileBuilderDisc' - - builder = self.ee.factory.get_builder_from_module( - self.model_name, mod_path) - - self.ee.factory.set_builders_to_coupling_builder(builder) - - self.ee.configure() - self.ee.display_treeview_nodes() - - self.ee.load_study_from_input_dict(inputs_dict) - - self.ee.execute() - - outputs = [f'{self.name}.{self.model_name}.{col}_array_mix' for col in self.columns_names] - - disc = self.ee.root_process.proxy_disciplines[0].mdo_discipline_wrapp.mdo_discipline - self.check_jacobian(derr_approx='complex_step', - inputs=self.coeff_jacobian, - outputs=outputs, - local_data=disc.local_data, - location=dirname(__file__), - discipline=disc, - filename='jacobian_investments_profile_builder_disc_poles.pkl', threshold=1e-5, )