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 Oct 16, 2024
2 parents 05bb45a + 449f743 commit 39360d5
Show file tree
Hide file tree
Showing 15 changed files with 220 additions and 861 deletions.
654 changes: 143 additions & 511 deletions energy_models/core/ccus/ccus.py

Large diffs are not rendered by default.

382 changes: 66 additions & 316 deletions energy_models/core/ccus/ccus_disc.py

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion energy_models/core/energy_mix/energy_mix.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class EnergyMix(BaseStream):
RESOURCE_LIST = ['natural_gas_resource', 'uranium_resource',
'coal_resource', 'oil_resource', 'copper_resource'] # , 'platinum_resource',]
RESOURCE_CONSUMPTION_UNIT = ResourceGlossary.UNITS['consumption']
CARBON_STORAGE_CONSTRAINT = 'carbon_storage_constraint'
energy_class_dict = {GaseousHydrogen.name: GaseousHydrogen,
LiquidFuel.name: LiquidFuel,
HydrotreatedOilFuel.name: HydrotreatedOilFuel,
Expand Down
6 changes: 0 additions & 6 deletions energy_models/core/energy_mix/energy_mix_disc.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,12 +783,6 @@ def compute_sos_jacobian(self):
-scaling_factor_energy_consumption * np.identity(
len(years)) / scaling_factor_energy_production * scaling_factor_energy_production * 0)

self.set_partial_derivative_for_other_types(
(GlossaryEnergy.StreamProductionDetailedValue, f'production {GlossaryEnergy.carbon_storage} ({GlossaryEnergy.unit_dicts[GlossaryEnergy.carbon_storage]})'),
(f'{GlossaryEnergy.carbon_storage}.{GlossaryEnergy.StreamConsumptionValue}', f'{GlossaryEnergy.carbon_capture} ({GlossaryEnergy.unit_dicts[GlossaryEnergy.carbon_capture]})'),
-scaling_factor_energy_consumption * np.identity(
len(years)) / scaling_factor_energy_production * scaling_factor_energy_production)

# -------------------------#
# ---- Prices gradients----#
# -------------------------#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ def __init__(self, name):
def compute_capital_recovery_factor(self, data_config):
return 1

def compute_other_streams_needs(self):
self.cost_details[f'{GlossaryEnergy.carbon_capture}_needs'] = 1.

def check_capex_unity(self, data_tocheck):
"""
Put all capex in $/kgCO2
Expand Down
14 changes: 7 additions & 7 deletions energy_models/glossaryenergy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1128,13 +1128,13 @@ class GlossaryEnergy(GlossaryWitnessCore):
WetCropResidues: [electricity], # transport fuel in stead of elec
Geothermal: [f"{heat}.{mediumtemperatureheat}"], # just electricity
BiomassBuryingFossilization: [biomass_dry], # add transport fuel
DeepOceanInjection: [carbon_capture], # add transport fuel
DeepSalineFormation: [carbon_capture], # add transport fuel
DepletedOilGas: [carbon_capture], # add transport fuel
EnhancedOilRecovery: [carbon_capture], # add transport fuel
GeologicMineralization: [carbon_capture], # add transport fuel
CarbonStorageTechno: [carbon_capture],
CropEnergy: [carbon_capture],
DeepOceanInjection: [], # add transport fuel
DeepSalineFormation: [], # add transport fuel
DepletedOilGas: [], # add transport fuel
EnhancedOilRecovery: [], # add transport fuel
GeologicMineralization: [], # add transport fuel
CarbonStorageTechno: [],
CropEnergy: [],
}

# dict of resources used by technos
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,6 @@ def setup_constraints(self):
list_aggr_type.append(FunctionManager.AGGR_TYPE_SMAX)
list_namespaces.append(GlossaryEnergy.NS_FUNCTIONS)

if GlossaryEnergy.carbon_storage in self.ccs_list:
list_var.extend(["carbon_storage_constraint"])
list_parent.extend([""])
list_ftype.extend([FunctionManagerDisc.INEQ_CONSTRAINT])
list_weight.extend([0.0])
list_aggr_type.append(FunctionManager.AGGR_TYPE_SMAX)
list_namespaces.append(GlossaryEnergy.NS_FUNCTIONS)

list_var.extend([EnergyMix.TOTAL_PROD_MINUS_MIN_PROD_CONSTRAINT_DF])
list_parent.extend(["Energy_constraints"])
list_ftype.extend([FunctionManagerDisc.INEQ_CONSTRAINT])
Expand Down
Binary file modified energy_models/tests/jacobian_pkls/jacobian_CCUS_disc.pkl
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 changes: 3 additions & 7 deletions energy_models/tests/l0_test_compute_ccus_disc.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ def test_01_CCUS_discipline(self):
f'{self.name}.{GlossaryEnergy.YearStart}': self.year_start,
f'{self.name}.{GlossaryEnergy.YearEnd}': self.year_end,
f'{self.name}.{GlossaryEnergy.energy_list}': self.energy_list,
f'{self.name}.{GlossaryEnergy.ccs_list}': [GlossaryEnergy.carbon_capture, GlossaryEnergy.carbon_storage],
f'{self.name}.scaling_factor_energy_production': self.scaling_factor_energy_production,
f'{self.name}.scaling_factor_energy_consumption': self.scaling_factor_energy_consumption,
f'{self.name}.{GlossaryEnergy.StreamProductionDetailedValue}': self.energy_production_detailed,
}
for energy in self.energy_list:
Expand Down Expand Up @@ -146,10 +143,9 @@ def test_01_CCUS_discipline(self):
f'{self.name}.{self.model_name}')[0]
filters = disc.get_chart_filter_list()
graph_list = disc.get_post_processing_list(filters)


# for graph in graph_list:
# graph.to_plotly().show()
for graph in graph_list:
#graph.to_plotly().show()
pass


if '__main__' == __name__:
Expand Down
3 changes: 1 addition & 2 deletions energy_models/tests/l1_test_gradient_ccus_disc.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,7 @@ def test_01_Consumption_ccus_disciplinejacobian(self):
f'{self.name}.{GlossaryEnergy.carbon_storage}.{GlossaryEnergy.LandUseRequiredValue}',
]
coupled_outputs = [f'{self.name}.co2_emissions_ccus_Gt',
f'{self.name}.CCS_price',
f'{self.name}.carbon_storage_constraint']
f'{self.name}.CCS_price',]

self.check_jacobian(location=dirname(__file__), filename=f'jacobian_{self.model_name}.pkl',
discipline=disc, step=1.0e-18, derr_approx='complex_step', threshold=1e-5,
Expand Down

0 comments on commit 39360d5

Please sign in to comment.