Skip to content

Commit

Permalink
merge post_integration to validation
Browse files Browse the repository at this point in the history
  • Loading branch information
b4pm-devops committed Jul 16, 2024
2 parents d6057ec + c79e6f5 commit f0c55aa
Show file tree
Hide file tree
Showing 447 changed files with 5,161 additions and 4,492 deletions.
253 changes: 127 additions & 126 deletions energy_models/core/ccus/ccus.py

Large diffs are not rendered by default.

89 changes: 32 additions & 57 deletions energy_models/core/ccus/ccus_disc.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
from energy_models.core.energy_mix.energy_mix import EnergyMix
from energy_models.core.stream_type.carbon_models.carbon_capture import CarbonCapture
from energy_models.core.stream_type.carbon_models.carbon_dioxyde import CO2
from energy_models.core.stream_type.carbon_models.carbon_storage import CarbonStorage
from energy_models.glossaryenergy import GlossaryEnergy


Expand Down Expand Up @@ -102,7 +101,7 @@ def __init__(self, sos_name, logger: logging.Logger):

def init_execution(self):
inputs_dict = self.get_sosdisc_inputs()
self.ccus_model = CCUS(GlossaryEnergy.CCUS)
self.ccus_model = CCUS(GlossaryEnergy.ccus_type)
self.ccus_model.configure_parameters(inputs_dict)

def setup_sos_disciplines(self):
Expand All @@ -112,7 +111,7 @@ def setup_sos_disciplines(self):

if GlossaryEnergy.ccs_list in self.get_data_in():
ccs_list = self.get_sosdisc_inputs(GlossaryEnergy.ccs_list)
self.update_default_ccs_list()
# self.update_default_ccs_list()
if ccs_list is not None:
for ccs_name in ccs_list:
dynamic_inputs[f'{ccs_name}.{GlossaryEnergy.EnergyConsumptionValue}'] = {
Expand All @@ -127,7 +126,7 @@ def setup_sos_disciplines(self):
'type': 'dataframe', 'unit': 'PWh', 'visibility': SoSWrapp.SHARED_VISIBILITY,
'namespace': GlossaryEnergy.NS_CCS,
'dynamic_dataframe_columns': True}
dynamic_inputs[f'{ccs_name}.{GlossaryEnergy.EnergyPricesValue}'] = {
dynamic_inputs[f'{ccs_name}.{GlossaryEnergy.StreamPricesValue}'] = {
'type': 'dataframe', 'unit': '$/MWh', 'visibility': SoSWrapp.SHARED_VISIBILITY,
'namespace': GlossaryEnergy.NS_CCS,
'dynamic_dataframe_columns': True}
Expand All @@ -152,30 +151,6 @@ def setup_sos_disciplines(self):
self.add_inputs(dynamic_inputs),
self.add_outputs(dynamic_outputs)

def update_default_ccs_list(self):
'''
Update the default value of technologies list with techno discipline below the ccs node and in possible values
'''

found_ccs = self.found_ccs_under_ccsmix()
self.set_dynamic_default_values({GlossaryEnergy.ccs_list: found_ccs})

def found_ccs_under_ccsmix(self):
'''
Set the default value of the ccs list and the ccs_list with discipline under the ccs_mix which are in possible values
'''
my_name = self.get_disc_full_name()
possible_ccs = CCUS.ccs_list
found_ccs_list = self.dm.get_discipline_names_with_starting_name(
my_name)
short_ccs_list = [name.split(
f'{my_name}.')[-1] for name in found_ccs_list if f'{my_name}.' in name]

possible_short_ccs_list = [
techno for techno in short_ccs_list if techno in possible_ccs]

return possible_short_ccs_list

def run(self):
# -- get inputs
inputs_dict = self.get_sosdisc_inputs()
Expand Down Expand Up @@ -253,10 +228,10 @@ def compute_sos_jacobian(self):
for energy_df in ccs_list:
list_columnsenergycons = list(
inputs_dict[f'{energy_df}.{GlossaryEnergy.EnergyConsumptionValue}'].columns)
if f'{energy} (TWh)' in list_columnsenergycons:
if f'{energy} ({GlossaryEnergy.energy_unit})' in list_columnsenergycons:
self.set_partial_derivative_for_other_types(
('co2_emissions_ccus', co2_emission_column),
(f'{energy_df}.{GlossaryEnergy.EnergyConsumptionValue}', f'{energy} (TWh)'),
(f'{energy_df}.{GlossaryEnergy.EnergyConsumptionValue}', f'{energy} ({GlossaryEnergy.energy_unit})'),
np.identity(len(years)) * scaling_factor_energy_consumption * value)
elif last_part_key == 'co2_per_use':
self.set_partial_derivative_for_other_types(
Expand All @@ -280,7 +255,7 @@ def compute_sos_jacobian(self):
'''
CO2 emissions Gt
'''
if co2_emission_column == f'{CarbonStorage.name} Limited by capture (Mt)':
if co2_emission_column == f'{GlossaryEnergy.carbon_storage} Limited by capture (Mt)':
co2_emission_column_upd = co2_emission_column.replace(
'(Mt)', '(Gt)')
if last_part_key == 'prod':
Expand All @@ -292,10 +267,10 @@ def compute_sos_jacobian(self):
for energy_df in ccs_list:
list_columnsenergycons = list(
inputs_dict[f'{energy_df}.{GlossaryEnergy.EnergyConsumptionValue}'].columns)
if f'{energy} (TWh)' in list_columnsenergycons:
if f'{energy} ({GlossaryEnergy.energy_unit})' in list_columnsenergycons:
self.set_partial_derivative_for_other_types(
('co2_emissions_ccus_Gt', co2_emission_column_upd),
(f'{energy_df}.{GlossaryEnergy.EnergyConsumptionValue}', f'{energy} (TWh)'),
(f'{energy_df}.{GlossaryEnergy.EnergyConsumptionValue}', f'{energy} ({GlossaryEnergy.energy_unit})'),
np.identity(len(years)) * scaling_factor_energy_consumption * value / 1.0e3)
elif last_part_key == 'co2_per_use':
self.set_partial_derivative_for_other_types(
Expand All @@ -306,16 +281,16 @@ def compute_sos_jacobian(self):
('co2_emissions_ccus_Gt', co2_emission_column_upd),
('co2_for_food', f'{CO2.name} for food (Mt)'), np.identity(len(years)) * value / 1.0e3)

elif energy_prod_info.startswith(f'{CarbonCapture.name} from energy mix (Mt)'):
elif energy_prod_info.startswith(f'{GlossaryEnergy.carbon_capture} from energy mix (Mt)'):
self.set_partial_derivative_for_other_types(
('co2_emissions_ccus_Gt', co2_emission_column_upd),
('carbon_capture_from_energy_mix', f'{CarbonCapture.name} from energy mix (Gt)'),
('carbon_capture_from_energy_mix', f'{GlossaryEnergy.carbon_capture} from energy mix (Gt)'),
np.identity(len(years)) * value)

elif energy_prod_info.startswith(f'{CarbonCapture.name} needed by energy mix (Mt)'):
elif energy_prod_info.startswith(f'{GlossaryEnergy.carbon_capture} needed by energy mix (Mt)'):
self.set_partial_derivative_for_other_types(
('co2_emissions_ccus_Gt', co2_emission_column_upd),
('co2_emissions_needed_by_energy_mix', f'{CarbonCapture.name} needed by energy mix (Gt)'),
('co2_emissions_needed_by_energy_mix', f'{GlossaryEnergy.carbon_capture} needed by energy mix (Gt)'),
np.identity(len(years)) * value)

else:
Expand Down Expand Up @@ -346,10 +321,10 @@ def compute_sos_jacobian(self):
for energy_df in ccs_list:
list_columnsenergycons = list(
inputs_dict[f'{energy_df}.{GlossaryEnergy.EnergyConsumptionValue}'].columns)
if f'{energy} (TWh)' in list_columnsenergycons:
if f'{energy} ({GlossaryEnergy.energy_unit})' in list_columnsenergycons:
self.set_partial_derivative_for_other_types(
(EnergyMix.CARBON_STORAGE_CONSTRAINT,),
(f'{energy_df}.{GlossaryEnergy.EnergyConsumptionValue}', f'{energy} (TWh)'),
(f'{energy_df}.{GlossaryEnergy.EnergyConsumptionValue}', f'{energy} ({GlossaryEnergy.energy_unit})'),
scaling_factor_energy_consumption * value)
elif last_part_key == 'co2_per_use':
self.set_partial_derivative_for_other_types(
Expand All @@ -358,15 +333,15 @@ def compute_sos_jacobian(self):
self.set_partial_derivative_for_other_types(
(EnergyMix.CARBON_STORAGE_CONSTRAINT,), ('co2_for_food', f'{CO2.name} for food (Mt)'), value)

elif energy_prod_info.startswith(f'{CarbonCapture.name} from energy mix (Mt)'):
elif energy_prod_info.startswith(f'{GlossaryEnergy.carbon_capture} from energy mix (Mt)'):
self.set_partial_derivative_for_other_types(
(EnergyMix.CARBON_STORAGE_CONSTRAINT,),
('carbon_capture_from_energy_mix', f'{CarbonCapture.name} from energy mix (Gt)'), value * 1e3)
('carbon_capture_from_energy_mix', f'{GlossaryEnergy.carbon_capture} from energy mix (Gt)'), value * 1e3)

elif energy_prod_info.startswith(f'{CarbonCapture.name} needed by energy mix (Mt)'):
elif energy_prod_info.startswith(f'{GlossaryEnergy.carbon_capture} needed by energy mix (Mt)'):
self.set_partial_derivative_for_other_types(
(EnergyMix.CARBON_STORAGE_CONSTRAINT,),
('co2_emissions_needed_by_energy_mix', f'{CarbonCapture.name} needed by energy mix (Gt)'),
('co2_emissions_needed_by_energy_mix', f'{GlossaryEnergy.carbon_capture} needed by energy mix (Gt)'),
value * 1e3)

else:
Expand All @@ -382,15 +357,15 @@ def compute_sos_jacobian(self):
(f'{energy}.{GlossaryEnergy.EnergyConsumptionValue}', last_part_key),
scaling_factor_energy_production * value)

if CarbonCapture.name in ccs_list:
if GlossaryEnergy.carbon_capture in ccs_list:
self.set_partial_derivative_for_other_types(
('CCS_price', 'ccs_price_per_tCO2'),
(f'{CarbonCapture.name}.{GlossaryEnergy.EnergyPricesValue}', CarbonCapture.name),
(f'{GlossaryEnergy.carbon_capture}.{GlossaryEnergy.StreamPricesValue}', GlossaryEnergy.carbon_capture),
np.identity(len(years)))
if CarbonStorage.name in ccs_list:
if GlossaryEnergy.carbon_storage in ccs_list:
self.set_partial_derivative_for_other_types(
('CCS_price', 'ccs_price_per_tCO2'),
(f'{CarbonStorage.name}.{GlossaryEnergy.EnergyPricesValue}', CarbonStorage.name),
(f'{GlossaryEnergy.carbon_storage}.{GlossaryEnergy.StreamPricesValue}', GlossaryEnergy.carbon_storage),
np.identity(len(years)))

def get_chart_filter_list(self):
Expand Down Expand Up @@ -487,20 +462,20 @@ def get_chart_co2_to_store(self):

serie = InstanciatedSeries(
x_serie_1,
(co2_emissions[f'{CarbonCapture.name} (Mt) from CC technos'].values / 1.0e3).tolist(),
(co2_emissions[f'{GlossaryEnergy.carbon_capture} ({GlossaryEnergy.mass_unit}) from CC technos'].values / 1.0e3).tolist(),
'CO2 captured from CC technos', 'bar')
new_chart.add_series(serie)

serie = InstanciatedSeries(
x_serie_1,
carbon_capture_from_energy_mix[f'{CarbonCapture.name} from energy mix (Gt)'].values.tolist(),
carbon_capture_from_energy_mix[f'{GlossaryEnergy.carbon_capture} from energy mix (Gt)'].values.tolist(),
'CO2 captured from energy mix', 'bar')
new_chart.add_series(serie)

serie = InstanciatedSeries(
x_serie_1,
(-co2_emissions_needed_by_energy_mix[f'{CarbonCapture.name} needed by energy mix (Gt)'].values).tolist(),
f'{CarbonCapture.name} used by energy mix' ,'bar')
(-co2_emissions_needed_by_energy_mix[f'{GlossaryEnergy.carbon_capture} needed by energy mix (Gt)'].values).tolist(),
f'{GlossaryEnergy.carbon_capture} used by energy mix' ,'bar')
new_chart.add_series(serie)

serie = InstanciatedSeries(
Expand All @@ -510,7 +485,7 @@ def get_chart_co2_to_store(self):

serie = InstanciatedSeries(
x_serie_1,
(co2_emissions[f'{CarbonCapture.name} to be stored (Mt)'].values / 1.0e3).tolist(), 'CO2 captured to store')
(co2_emissions[f'{GlossaryEnergy.carbon_capture} to be stored (Mt)'].values / 1.0e3).tolist(), 'CO2 captured to store')
new_chart.add_series(serie)

return new_chart
Expand All @@ -528,7 +503,7 @@ def get_chart_co2_limited_storage(self):
x_serie_1 = co2_emissions[GlossaryEnergy.Years].values.tolist()
serie = InstanciatedSeries(
x_serie_1,
(co2_emissions[f'{CarbonCapture.name} to be stored (Mt)'].values / 1.0e3).tolist(), 'CO2 captured to store')
(co2_emissions[f'{GlossaryEnergy.carbon_capture} to be stored (Mt)'].values / 1.0e3).tolist(), 'CO2 captured to store')
new_chart.add_series(serie)

serie = InstanciatedSeries(
Expand All @@ -538,7 +513,7 @@ def get_chart_co2_limited_storage(self):

serie = InstanciatedSeries(
x_serie_1,
(co2_emissions[f'{CarbonStorage.name} Limited by capture (Mt)'].values / 1.0e3).tolist(),
(co2_emissions[f'{GlossaryEnergy.carbon_storage} Limited by capture (Mt)'].values / 1.0e3).tolist(),
'CO2 captured and stored')
new_chart.add_series(serie)

Expand All @@ -562,12 +537,12 @@ def get_chart_co2_emissions_sources(self):

serie = InstanciatedSeries(
x_serie_1,
(co2_emissions[f'Total {CarbonCapture.flue_gas_name} (Mt)'].values / 1.0e3).tolist(),
(co2_emissions[f'Total {CarbonCapture.flue_gas_name} ({GlossaryEnergy.mass_unit})'].values / 1.0e3).tolist(),
'Flue gas from plants')
new_chart.add_series(serie)

serie = InstanciatedSeries(
x_serie_1, (co2_emissions[f'{CarbonCapture.name} from energy mix (Mt)'].values / 1.0e3).tolist(),
x_serie_1, (co2_emissions[f'{GlossaryEnergy.carbon_capture} from energy mix (Mt)'].values / 1.0e3).tolist(),
'Carbon capture from energy mix (FT or Sabatier)')
new_chart.add_series(serie)

Expand Down Expand Up @@ -602,7 +577,7 @@ def get_chart_carbon_storage_constraint(self):
visible_line = True

new_series = InstanciatedSeries(
years, list(co2_emissions[f'{CarbonStorage.name} Limited by capture (Gt)'].cumsum().values),
years, list(co2_emissions[f'{GlossaryEnergy.carbon_storage} Limited by capture (Gt)'].cumsum().values),
'cumulative sum of carbon capture (Gt)', 'lines', visible_line)

new_chart.series.append(new_series)
Expand Down
Loading

0 comments on commit f0c55aa

Please sign in to comment.