From cc9cdcba9edbde3a90b7e75a1bfd28f8c3e54480 Mon Sep 17 00:00:00 2001 From: perrotcap Date: Sun, 13 Oct 2024 12:13:35 +0200 Subject: [PATCH] fix CCUS discipline scaling prod --- energy_models/core/ccus/ccus.py | 17 ++++++++++++----- energy_models/core/ccus/ccus_disc.py | 7 ++----- .../tests/jacobian_pkls/jacobian_CCUS_disc.pkl | Bin 604 -> 580 bytes 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/energy_models/core/ccus/ccus.py b/energy_models/core/ccus/ccus.py index d0f6c87e..9e47254c 100644 --- a/energy_models/core/ccus/ccus.py +++ b/energy_models/core/ccus/ccus.py @@ -67,7 +67,7 @@ def configure_parameters(self, inputs_dict): self.ccs_list = [GlossaryEnergy.carbon_capture, GlossaryEnergy.carbon_storage] def compute_carbon_storage_capacity(self): - total_carbon_storage_by_invest_mt = self.inputs_dict[f"{GlossaryEnergy.carbon_storage}.{GlossaryEnergy.EnergyProductionValue}"][ GlossaryEnergy.carbon_storage].values + total_carbon_storage_by_invest_mt = self.inputs_dict[f"{GlossaryEnergy.carbon_storage}.{GlossaryEnergy.EnergyProductionValue}"][ GlossaryEnergy.carbon_storage].values * self.inputs_dict['scaling_factor_energy_production'] self.outputs_dict['carbon_storage_capacity (Gt)'] = pd.DataFrame({ GlossaryEnergy.Years: self.years, @@ -84,6 +84,7 @@ def compute_co2_emissions(self): # production of CCS technos are in Mt carbon_capture_prod_mt = self.inputs_dict[f"{GlossaryEnergy.carbon_capture}.{GlossaryEnergy.EnergyProductionValue}"][GlossaryEnergy.carbon_capture].values carbon_storage_prod_mt = self.inputs_dict[f"{GlossaryEnergy.carbon_storage}.{GlossaryEnergy.EnergyProductionValue}"][GlossaryEnergy.carbon_storage].values + scaling_factor_energy_prod = self.inputs_dict['scaling_factor_energy_production'] # Outputs are in Gt (for automatic differentiation purpose : coupling output var is in Gt) carbon_capture_to_be_stored_gt, carbon_storage_limited_by_capture_gt, carbon_storage_gt, carbon_capture_from_cc_technos_gt = compute_carbon_storage_limited_by_capture_gt( @@ -91,7 +92,8 @@ def compute_co2_emissions(self): carbon_storage_prod_mt=carbon_storage_prod_mt, carbon_capture_from_energy_mix_gt=carbon_capture_from_energy_mix_gt, co2_emissions_needed_by_energy_mix_gt=co2_emissions_needed_by_energy_mix_gt, - co2_for_food_mt=co2_for_food_mt + co2_for_food_mt=co2_for_food_mt, + scaling_factor_energy_prod=scaling_factor_energy_prod ) self.outputs_dict['co2_emissions_ccus'] = pd.DataFrame({ @@ -130,6 +132,7 @@ def grad_co2_emissions_ccus_Gt(self): # production of CCS technos are in Mt carbon_capture_prod_mt = self.inputs_dict[f"{GlossaryEnergy.carbon_capture}.{GlossaryEnergy.EnergyProductionValue}"][GlossaryEnergy.carbon_capture].values carbon_storage_prod_mt = self.inputs_dict[f"{GlossaryEnergy.carbon_storage}.{GlossaryEnergy.EnergyProductionValue}"][GlossaryEnergy.carbon_storage].values + scaling_factor_energy_prod = self.inputs_dict['scaling_factor_energy_production'] jac_carbon_capture_from_cc_prod, jac_carbon_capture_from_cs_prod, jac_carbon_capture_from_energy_mix, jac_co2_emissions_needed_by_energy_mix =\ compute_carbon_storage_limited_by_capture_gt_der( @@ -138,6 +141,7 @@ def grad_co2_emissions_ccus_Gt(self): carbon_capture_from_energy_mix_gt=carbon_capture_from_energy_mix_gt, co2_emissions_needed_by_energy_mix_gt=co2_emissions_needed_by_energy_mix_gt, co2_for_food_mt=co2_for_food_mt, + scaling_factor_energy_prod=scaling_factor_energy_prod ) # input_name : (column_name, grad value) out = { @@ -156,6 +160,7 @@ def compute_carbon_storage_limited_by_capture_gt( carbon_capture_from_energy_mix_gt: np.ndarray, co2_emissions_needed_by_energy_mix_gt: np.ndarray, co2_for_food_mt: np.ndarray, + scaling_factor_energy_prod: float ): ''' The carbon stored by invest is limited by the carbon to stored @@ -165,13 +170,13 @@ def compute_carbon_storage_limited_by_capture_gt( carbon_capture_from_cc_technos_mt = carbon_capture_prod_mt carbon_capture_to_be_stored_mt = ( - carbon_capture_from_cc_technos_mt + + carbon_capture_from_cc_technos_mt * scaling_factor_energy_prod + carbon_capture_from_energy_mix_gt * 1e3 - 0 * co2_emissions_needed_by_energy_mix_gt * 1e3 - 0 * co2_for_food_mt ) - carbon_storage_limited_by_capture_mt = np.minimum(carbon_capture_to_be_stored_mt, carbon_storage_prod_mt) + carbon_storage_limited_by_capture_mt = np.minimum(carbon_capture_to_be_stored_mt, carbon_storage_prod_mt * scaling_factor_energy_prod) return carbon_capture_to_be_stored_mt / 1e3, carbon_storage_limited_by_capture_mt / 1e3, carbon_storage_prod_mt / 1e3, carbon_capture_from_cc_technos_mt / 1e3 @@ -181,12 +186,14 @@ def compute_carbon_storage_limited_by_capture_gt_der( carbon_capture_from_energy_mix_gt: np.ndarray, co2_emissions_needed_by_energy_mix_gt: np.ndarray, co2_for_food_mt: np.ndarray, + scaling_factor_energy_prod: float, ): args = (carbon_capture_prod_mt, carbon_storage_prod_mt, carbon_capture_from_energy_mix_gt, co2_emissions_needed_by_energy_mix_gt, - co2_for_food_mt,) + co2_for_food_mt, + scaling_factor_energy_prod) jac_carbon_capture_from_cc_prod = jacobian(lambda *args: compute_carbon_storage_limited_by_capture_gt(*args)[1], 0) jac_carbon_capture_from_cs_prod = jacobian(lambda *args: compute_carbon_storage_limited_by_capture_gt(*args)[1], 1) diff --git a/energy_models/core/ccus/ccus_disc.py b/energy_models/core/ccus/ccus_disc.py index 2307bde5..06a8a10d 100644 --- a/energy_models/core/ccus/ccus_disc.py +++ b/energy_models/core/ccus/ccus_disc.py @@ -53,15 +53,12 @@ class CCUS_Discipline(SoSWrapp): GlossaryEnergy.YearStart: ClimateEcoDiscipline.YEAR_START_DESC_IN, GlossaryEnergy.YearEnd: {'type': 'int', 'unit': 'year', 'visibility': 'Shared', 'namespace': 'ns_public', 'range': [2000,2300]}, - 'alpha': {'type': 'float', 'range': [0., 1.], 'default': 0.5, 'unit': '-', - 'visibility': SoSWrapp.SHARED_VISIBILITY, 'namespace': 'ns_energy_study'}, - '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), 'carbon_capture needed by energy mix (Gt)': ('float', None, True), }, }, + 'scaling_factor_energy_production': {'type': 'float', 'default': 1e3, 'user_level': 2, 'visibility': SoSWrapp.SHARED_VISIBILITY, 'namespace': 'ns_public'}, 'carbon_capture_from_energy_mix': {'type': 'dataframe', 'unit': 'Gt', 'visibility': SoSWrapp.SHARED_VISIBILITY, 'namespace': 'ns_energy', 'dataframe_descriptor': {GlossaryEnergy.Years: ('float', None, True), @@ -303,7 +300,7 @@ def get_chart_co2_limited_storage(self): (co2_emissions[f'{GlossaryEnergy.carbon_storage} Limited by capture (Mt)'].values / 1.0e3).tolist(), 'CO2 captured and stored', 'bar') new_chart.add_series(serie) - + new_chart.to_plotly().show() return new_chart def get_chart_co2_emissions_sources(self): diff --git a/energy_models/tests/jacobian_pkls/jacobian_CCUS_disc.pkl b/energy_models/tests/jacobian_pkls/jacobian_CCUS_disc.pkl index 020b42f7ade3d058eebe9d21d04b44575de1c73d..250dc2a8652a1b33154ea9dea270a3c844201953 100644 GIT binary patch literal 580 zcmV-K0=xY}T4*^jL0KkKSpy)(Ul26O)aUA>CSLr;sHg7O5ko%>qM|Fh~ z(icCANLu8!%I>P`FI1MTp)ImZ{-|fzV8-^_Q~F5nHjC&o_H?~?Ji1Ig*$&i3QZ-1- z#KVrDi2IbN(kVI4C)0&YBo6|+X4)RmDvfVR;r2XOsQHM-`kC7)Gv9kf!G)ntH6u>Z z$Aw~+Xk520WWOw~_Oi_RRH~`HR%`6VpwLo_mkokqtCgbrgit6|?Xi@r+3;~Ws5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