Skip to content

Commit

Permalink
Merge branch 'develop' into integration
Browse files Browse the repository at this point in the history
  • Loading branch information
perrotcap committed Sep 4, 2024
2 parents 1172f8b + 78fa794 commit 2a987f6
Show file tree
Hide file tree
Showing 38 changed files with 445 additions and 440 deletions.
6 changes: 3 additions & 3 deletions energy_models/core/ccus/ccus.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ def configure_parameters_update(self, inputs_dict):
self.sub_prices[element] = inputs_dict[f'{element}.{GlossaryEnergy.StreamPricesValue}'][element]
self.sub_production_dict[element] = inputs_dict[f'{element}.{GlossaryEnergy.EnergyProductionValue}'] * \
self.scaling_factor_energy_production
self.sub_consumption_dict[element] = inputs_dict[f'{element}.{GlossaryEnergy.EnergyConsumptionValue}'] * \
self.sub_consumption_dict[element] = inputs_dict[f'{element}.{GlossaryEnergy.StreamConsumptionValue}'] * \
self.scaling_factor_energy_consumption
self.sub_consumption_woratio_dict[element] = inputs_dict[f'{element}.{GlossaryEnergy.EnergyConsumptionWithoutRatioValue}'] * \
self.sub_consumption_woratio_dict[element] = inputs_dict[f'{element}.{GlossaryEnergy.StreamConsumptionWithoutRatioValue}'] * \
self.scaling_factor_energy_consumption

self.stream_prices = self.sub_prices.copy(deep=True)
Expand All @@ -123,7 +123,7 @@ def configure_parameters_update(self, inputs_dict):
if elements in self.resource_list:
self.all_resource_demand[elements] = self.all_resource_demand[elements] + \
inputs_dict[
f'{element}.{GlossaryEnergy.EnergyConsumptionValue}'][
f'{element}.{GlossaryEnergy.StreamConsumptionValue}'][
elements].values * \
self.scaling_factor_energy_consumption

Expand Down
28 changes: 14 additions & 14 deletions energy_models/core/ccus/ccus_disc.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ def setup_sos_disciplines(self):
# self.update_default_ccs_list()
if ccs_list is not None:
for ccs_name in ccs_list:
dynamic_inputs[f'{ccs_name}.{GlossaryEnergy.EnergyConsumptionValue}'] = {
dynamic_inputs[f'{ccs_name}.{GlossaryEnergy.StreamConsumptionValue}'] = {
'type': 'dataframe', 'unit': 'PWh', 'visibility': SoSWrapp.SHARED_VISIBILITY,
'namespace': GlossaryEnergy.NS_CCS,
"dynamic_dataframe_columns": True}
dynamic_inputs[f'{ccs_name}.{GlossaryEnergy.EnergyConsumptionWithoutRatioValue}'] = {
dynamic_inputs[f'{ccs_name}.{GlossaryEnergy.StreamConsumptionWithoutRatioValue}'] = {
'type': 'dataframe', 'unit': 'PWh', 'visibility': SoSWrapp.SHARED_VISIBILITY,
'namespace': GlossaryEnergy.NS_CCS,
"dynamic_dataframe_columns": True}
Expand Down Expand Up @@ -191,18 +191,18 @@ def compute_sos_jacobian(self):
for ccs in ccs_list:
sub_production_dict[ccs] = inputs_dict[f'{ccs}.{GlossaryEnergy.EnergyProductionValue}'] * \
scaling_factor_energy_production
sub_consumption_dict[ccs] = inputs_dict[f'{ccs}.{GlossaryEnergy.EnergyConsumptionValue}'] * \
sub_consumption_dict[ccs] = inputs_dict[f'{ccs}.{GlossaryEnergy.StreamConsumptionValue}'] * \
scaling_factor_energy_consumption

# -------------------------------#
# ---Resource Demand gradients---#
# -------------------------------#
resource_list = EnergyMix.RESOURCE_LIST
for ccs in ccs_list:
for resource in inputs_dict[f'{ccs}.{GlossaryEnergy.EnergyConsumptionValue}']:
for resource in inputs_dict[f'{ccs}.{GlossaryEnergy.StreamConsumptionValue}']:
if resource in resource_list:
self.set_partial_derivative_for_other_types(('All_Demand', resource), (
f'{ccs}.{GlossaryEnergy.EnergyConsumptionValue}', resource),
f'{ccs}.{GlossaryEnergy.StreamConsumptionValue}', resource),
scaling_factor_energy_consumption * np.identity(
len(years)))

Expand Down Expand Up @@ -230,11 +230,11 @@ def compute_sos_jacobian(self):
elif last_part_key == 'cons':
for energy_df in ccs_list:
list_columnsenergycons = list(
inputs_dict[f'{energy_df}.{GlossaryEnergy.EnergyConsumptionValue}'].columns)
inputs_dict[f'{energy_df}.{GlossaryEnergy.StreamConsumptionValue}'].columns)
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} ({GlossaryEnergy.energy_unit})'),
(f'{energy_df}.{GlossaryEnergy.StreamConsumptionValue}', 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 @@ -252,7 +252,7 @@ def compute_sos_jacobian(self):
elif very_last_part_key == 'cons':
self.set_partial_derivative_for_other_types(
('co2_emissions_ccus', co2_emission_column),
(f'{energy}.{GlossaryEnergy.EnergyConsumptionValue}', last_part_key),
(f'{energy}.{GlossaryEnergy.StreamConsumptionValue}', last_part_key),
np.identity(len(years)) * scaling_factor_energy_production * value)

'''
Expand All @@ -269,11 +269,11 @@ def compute_sos_jacobian(self):
elif last_part_key == 'cons':
for energy_df in ccs_list:
list_columnsenergycons = list(
inputs_dict[f'{energy_df}.{GlossaryEnergy.EnergyConsumptionValue}'].columns)
inputs_dict[f'{energy_df}.{GlossaryEnergy.StreamConsumptionValue}'].columns)
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} ({GlossaryEnergy.energy_unit})'),
(f'{energy_df}.{GlossaryEnergy.StreamConsumptionValue}', 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 Down Expand Up @@ -307,7 +307,7 @@ def compute_sos_jacobian(self):
elif very_last_part_key == 'cons':
self.set_partial_derivative_for_other_types(
('co2_emissions_ccus_Gt', co2_emission_column_upd),
(f'{energy}.{GlossaryEnergy.EnergyConsumptionValue}', last_part_key),
(f'{energy}.{GlossaryEnergy.StreamConsumptionValue}', last_part_key),
np.identity(len(years)) * scaling_factor_energy_production * value / 1.0e3)

'''
Expand All @@ -323,11 +323,11 @@ def compute_sos_jacobian(self):
elif last_part_key == 'cons' and energy in ccs_list:
for energy_df in ccs_list:
list_columnsenergycons = list(
inputs_dict[f'{energy_df}.{GlossaryEnergy.EnergyConsumptionValue}'].columns)
inputs_dict[f'{energy_df}.{GlossaryEnergy.StreamConsumptionValue}'].columns)
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} ({GlossaryEnergy.energy_unit})'),
(f'{energy_df}.{GlossaryEnergy.StreamConsumptionValue}', 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 Down Expand Up @@ -357,7 +357,7 @@ def compute_sos_jacobian(self):
elif very_last_part_key == 'cons':
self.set_partial_derivative_for_other_types(
(EnergyMix.CARBON_STORAGE_CONSTRAINT,),
(f'{energy}.{GlossaryEnergy.EnergyConsumptionValue}', last_part_key),
(f'{energy}.{GlossaryEnergy.StreamConsumptionValue}', last_part_key),
scaling_factor_energy_production * value)

if GlossaryEnergy.carbon_capture in ccs_list:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ def configure_parameters_update(self, inputs_dict):
self.co2_per_use[energy] = inputs_dict[f'{energy}.{GlossaryEnergy.CO2PerUse}'][GlossaryEnergy.CO2PerUse]
self.sub_production_dict[energy] = inputs_dict[f'{energy}.{GlossaryEnergy.EnergyProductionValue}'] * \
self.scaling_factor_energy_production
self.sub_consumption_dict[energy] = inputs_dict[f'{energy}.{GlossaryEnergy.EnergyConsumptionValue}'] * \
self.sub_consumption_dict[energy] = inputs_dict[f'{energy}.{GlossaryEnergy.StreamConsumptionValue}'] * \
self.scaling_factor_energy_consumption

for energy in self.ccs_list:
self.sub_production_dict[energy] = inputs_dict[f'{energy}.{GlossaryEnergy.EnergyProductionValue}'] * \
self.scaling_factor_energy_production

self.energy_production_detailed = inputs_dict[GlossaryEnergy.EnergyProductionDetailedValue]
self.energy_production_detailed = inputs_dict[GlossaryEnergy.StreamProductionDetailedValue]

def compute_CO2_emissions(self):
'''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ConsumptionCO2EmissionsDiscipline(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'},
GlossaryEnergy.EnergyProductionDetailedValue: {'type': 'dataframe', 'unit': 'TWh',
GlossaryEnergy.StreamProductionDetailedValue: {'type': 'dataframe', 'unit': 'TWh',
'visibility': SoSWrapp.SHARED_VISIBILITY,
'namespace': 'ns_energy',
'dataframe_descriptor': {
Expand Down Expand Up @@ -143,7 +143,7 @@ def setup_sos_disciplines(self):
'visbility': 'Shared', 'namespace': GlossaryEnergy.NS_WITNESS
})
dynamic_inputs[f'{AgricultureMixDiscipline.name}.{GlossaryEnergy.CO2PerUse}'] = co2_per_use_var
dynamic_inputs[f'{AgricultureMixDiscipline.name}.{GlossaryEnergy.EnergyConsumptionValue}'] = {
dynamic_inputs[f'{AgricultureMixDiscipline.name}.{GlossaryEnergy.StreamConsumptionValue}'] = {
'type': 'dataframe', 'unit': 'PWh', 'namespace': GlossaryEnergy.NS_WITNESS,
'visibility': SoSWrapp.SHARED_VISIBILITY,
'dataframe_descriptor': {GlossaryEnergy.Years: ('float', None, True),
Expand All @@ -163,7 +163,7 @@ def setup_sos_disciplines(self):
'namespace': 'ns_energy',
'dataframe_descriptor': {GlossaryEnergy.Years: ('float', None, True),
GlossaryEnergy.CO2PerUse: ('float', None, True), }}
dynamic_inputs[f'{energy}.{GlossaryEnergy.EnergyConsumptionValue}'] = {
dynamic_inputs[f'{energy}.{GlossaryEnergy.StreamConsumptionValue}'] = {
'type': 'dataframe', 'unit': 'PWh',
'visibility': SoSWrapp.SHARED_VISIBILITY,
'namespace': 'ns_energy',
Expand Down Expand Up @@ -197,8 +197,8 @@ def run(self):
inputs_dict.update(inputs_dict_orig)
energy_list = self.get_sosdisc_inputs(GlossaryEnergy.energy_list)
if GlossaryEnergy.biomass_dry in energy_list:
inputs_dict[f'{BiomassDry.name}.{GlossaryEnergy.EnergyConsumptionValue}'] = inputs_dict_orig.pop(
f'{AgricultureMixDiscipline.name}.{GlossaryEnergy.EnergyConsumptionValue}')
inputs_dict[f'{BiomassDry.name}.{GlossaryEnergy.StreamConsumptionValue}'] = inputs_dict_orig.pop(
f'{AgricultureMixDiscipline.name}.{GlossaryEnergy.StreamConsumptionValue}')
inputs_dict[f'{BiomassDry.name}.{GlossaryEnergy.EnergyProductionValue}'] = inputs_dict_orig.pop(
f'{AgricultureMixDiscipline.name}.{GlossaryEnergy.EnergyProductionValue}')
inputs_dict[f'{BiomassDry.name}.{GlossaryEnergy.CO2PerUse}'] = inputs_dict_orig.pop(
Expand All @@ -224,7 +224,7 @@ def compute_sos_jacobian(self):
CO2_emissions_by_use_sources = outputs_dict['CO2_emissions_by_use_sources']
CO2_emissions_by_use_sinks = outputs_dict['CO2_emissions_by_use_sinks']
energy_production_detailed = self.get_sosdisc_inputs(
GlossaryEnergy.EnergyProductionDetailedValue)
GlossaryEnergy.StreamProductionDetailedValue)

# ------------------------------------#
# -- CO2 emissions sources gradients--#
Expand All @@ -246,7 +246,7 @@ def compute_sos_jacobian(self):
self.set_partial_derivative_for_other_types(
('CO2_emissions_by_use_sources',
co2_emission_column),
(GlossaryEnergy.EnergyProductionDetailedValue, f'production {energy} ({GlossaryEnergy.energy_unit})'),
(GlossaryEnergy.StreamProductionDetailedValue, f'production {energy} ({GlossaryEnergy.energy_unit})'),
np.identity(len(years)) * value / 1e3)
else:
self.set_partial_derivative_for_other_types(
Expand All @@ -256,11 +256,11 @@ def compute_sos_jacobian(self):
elif last_part_key == 'cons':
for energy_df in energy_list:
list_columnsenergycons = list(
inputs_dict[f'{energy_df}.{GlossaryEnergy.EnergyConsumptionValue}'].columns)
inputs_dict[f'{energy_df}.{GlossaryEnergy.StreamConsumptionValue}'].columns)
if f'{energy} ({GlossaryEnergy.energy_unit})' in list_columnsenergycons:
self.set_partial_derivative_for_other_types(
('CO2_emissions_by_use_sources', co2_emission_column), (
f'{energy_df}.{GlossaryEnergy.EnergyConsumptionValue}', f'{energy} ({GlossaryEnergy.energy_unit})'),
f'{energy_df}.{GlossaryEnergy.StreamConsumptionValue}', f'{energy} ({GlossaryEnergy.energy_unit})'),
np.identity(len(years)) * scaling_factor_energy_consumption * value / 1e3)
elif last_part_key == 'co2_per_use':
self.set_partial_derivative_for_other_types(
Expand All @@ -278,7 +278,7 @@ def compute_sos_jacobian(self):
elif very_last_part_key == 'cons':
self.set_partial_derivative_for_other_types(
('CO2_emissions_by_use_sources', co2_emission_column), (
f'{ns_energy}.{GlossaryEnergy.EnergyConsumptionValue}', last_part_key),
f'{ns_energy}.{GlossaryEnergy.StreamConsumptionValue}', last_part_key),
np.identity(len(years)) * scaling_factor_energy_production * value / 1e3)

# gradient for carbone capture and storage technos producing co2
Expand Down Expand Up @@ -314,11 +314,11 @@ def compute_sos_jacobian(self):
elif last_part_key == 'cons':
for energy_df in energy_list:
list_columnsenergycons = list(
inputs_dict[f'{energy_df}.{GlossaryEnergy.EnergyConsumptionValue}'].columns)
inputs_dict[f'{energy_df}.{GlossaryEnergy.StreamConsumptionValue}'].columns)
if f'{energy} ({GlossaryEnergy.energy_unit})' in list_columnsenergycons:
self.set_partial_derivative_for_other_types(
('CO2_emissions_by_use_sinks', co2_emission_column), (
f'{energy_df}.{GlossaryEnergy.EnergyConsumptionValue}', f'{energy} ({GlossaryEnergy.energy_unit})'),
f'{energy_df}.{GlossaryEnergy.StreamConsumptionValue}', f'{energy} ({GlossaryEnergy.energy_unit})'),
np.identity(len(years)) * scaling_factor_energy_consumption * value / 1e3)
elif last_part_key == 'co2_per_use':
self.set_partial_derivative_for_other_types(
Expand All @@ -336,7 +336,7 @@ def compute_sos_jacobian(self):
elif very_last_part_key == 'cons':
self.set_partial_derivative_for_other_types(
('CO2_emissions_by_use_sinks', co2_emission_column), (
f'{ns_energy}.{GlossaryEnergy.EnergyConsumptionValue}', last_part_key),
f'{ns_energy}.{GlossaryEnergy.StreamConsumptionValue}', last_part_key),
np.identity(len(years)) * scaling_factor_energy_production * value / 1e3)

def get_chart_filter_list(self):
Expand Down
2 changes: 1 addition & 1 deletion energy_models/core/demand/energy_demand.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def configure_parameters_update(self, inputs_dict):
'''
Update parameters at each execution
'''
self.energy_production_detailed = inputs_dict[GlossaryEnergy.EnergyProductionDetailedValue]
self.energy_production_detailed = inputs_dict[GlossaryEnergy.StreamProductionDetailedValue]
self.population_df = inputs_dict[GlossaryEnergy.PopulationDfValue]

def compute(self):
Expand Down
Loading

0 comments on commit 2a987f6

Please sign in to comment.