Add a New Technology¶
In this tutorial, we will learn how to add a new technology to the EnergyScope model using the add_technology
function. This allows you to define the characteristics of a new technology and integrate it into an existing energy system model, such as infrastructure
. We will go through each step required to successfully add the technology, solve the model, and visualize the results.
Step-by-Step Instructions¶
To add a new technology, follow these steps:
1. Set Up Your Project Environment¶
Ensure that your project directory is properly structured and contains the necessary files and folders. Your project should look like this:
your_project/
├── output/ # This folder will contain the .dat file for the new technology
├── your_script.py # The script where you will add the new technology
output/
: Directory where the generated.dat
file for the new technology will be saved.your_script.py
: Python script where you will write the code to add the new technology.
2. Import Necessary Libraries and Initialize the Model¶
First, import the required classes and functions from the energyscope
package and initialize the existing model (e.g., infrastructure
).
from energyscope.energyscope import Energyscope
from energyscope.result import postprocessing
from energyscope.plots import plot_sankey
from energyscope.models import infrastructure_ch_2050
# Initialize the EnergyScope model with the 'infrastructure' dataset
es_infra_ch = Energyscope(model=infrastructure_ch_2050)
Energyscope
: Main class to interact with the EnergyScope model.postprocessing
: Function to process results after the model run.plot_sankey
: Function to generate a Sankey diagram for visualization.infrastructure
: Predefined model configuration focusing on energy infrastructure.
3. Define the New Technology Parameters¶
Next, define a dictionary containing all the necessary parameters for your new technology. These parameters include technical, economic, and environmental attributes.
# Define the parameters for the new technology
name = 'Newtech'
new_tech_params = {
'name': name,
'c_inv': 0.01, # Investment cost (MCHF/GW)
'c_maint': 40, # Maintenance cost (MCHF/GW)
'gwp_constr': 3900, # Greenhouse gas emissions (ktCO2eq/GW)
'lifetime': 30, # Lifetime of the technology (years)
'c_p': 1, # Capacity factor (%)
'fmin_perc': 0, # Minimum % of production for its sector (%)
'fmax_perc': 1, # Maximum % of production for its sector (%)
'f_min': 0, # Minimum installed capacity (GW)
'f_max': 20, # Maximum installed capacity (GW)
'c_p_t': { # Variable capacity factor (%) per time step
1: 0.0848,
2: 0.1504,
3: 0.1920,
4: 0.2448,
5: 0.2496,
6: 0.2512,
7: 0.2624,
8: 0.2496,
9: 0.2048,
10: 0.1408,
11: 0.0832,
12: 0.0576
},
'layers_in_out': { # Input and output layers with their coefficients
'ELECTRICITY_MV': 0.5,
'HEAT_LOW_T_DHN': 1,
'WOOD': -1
},
'tech_sets': { # Sets to which the technology belongs
'TECHNOLOGIES_OF_END_USES_TYPE': ['HEAT_LOW_T_DHN', 'ELECTRICITY_MV']
}
}
- Key Parameters:
name
: Unique identifier for the technology.c_inv
: Investment cost per GW.c_maint
: Annual maintenance cost per GW.gwp_constr
: Greenhouse gas emissions associated per GW installed.lifetime
: Expected operational lifetime.c_p
: Capacity factor.fmin_perc
,fmax_perc
: Minimum and maximum % of production for its sector.f_min
,f_max
: Minimum and maximum installed capacity in GW.c_p_t
: Variable capacity factor (%) per time step (e.g., months).layers_in_out
: Defines the input and output flows between layers, with positive values for outputs and negative for inputs.tech_sets
: Specifies the sets or categories the technology belongs to, which affects how it interacts with other model components.
4. Add the New Technology to the Model¶
Use the add_technology
method of the Energyscope
class to integrate the new technology into the model. This method generates the necessary .dat
file in the specified output directory.
# Add the new technology and save the .dat file in the output folder
es_infra_ch.add_technology(tech_parameters=new_tech_params, output_dir="./tutorial_output")
trl is not defined, default value: 9 will be used. Technology 'Newtech' successfully added and saved in ./tutorial_output/Newtech.dat
tech_parameters
: The dictionary containing your new technology's parameters.output_dir
: Directory where the generated.dat
file will be saved.
Note: Ensure that the
output/
directory exists in your project folder. The.dat
file is essential as it contains the data that the EnergyScope model uses during the optimization process.
5. Solve the Model with the New Technology¶
Now that the new technology is added, solve the model to see how the inclusion of the new technology affects the energy system configuration.
# Solve the model
results_ch = es_infra_ch.calc()
Gurobi 11.0.0:Gurobi 11.0.0: optimal solution; objective 8151.37247 4940 simplex iteration(s) 1 branching node(s) absmipgap=0.102407, relmipgap=1.25632e-05
results_ch
: This variable stores the results of the model run, including variables, parameters, and other outputs.
Note: The computation time may vary depending on the complexity of the model and the capabilities of your system.
6. Post-Process and Visualize the Results¶
After solving the model, you can analyze the results by post-processing and visualizing them.
Post-Process the Results¶
# Post-process the results to compute KPIs and prepare for visualization
results_ch = postprocessing(results_ch)
- The
postprocessing
function enriches the results with additional analysis, making them ready for interpretation and plotting.
Generate and Display a Sankey Diagram¶
A Sankey diagram visually represents the energy flows within the system, showing how the new technology interacts with other components.
# Generate the Sankey diagram based on the results
fig = plot_sankey(results_ch)
fig.show()
fig
: The figure object containing the Sankey diagram.fig.show()
: Displays the diagram within the notebook or interactive environment.
Optional: You can save the Sankey diagram as an image or HTML file for external use.
# Save the Sankey diagram as an image
# fig.write_image('output/sankey_newtech.png')
# Save the Sankey diagram as an HTML file
# fig.write_html('output/sankey_newtech.html')
# Access the capacities of technologies from the results
tech_capacities = results_ch.variables['F_Mult']
# Display the capacity of the new technology
tech_capacities.loc['Newtech']
F_Mult 0.000018 Run 0.000000 Name: Newtech, dtype: float64
F_Mult
: Represents the capacities or flow multipliers of technologies.- This step verifies whether
Newtech
appears in the results and provides its capacity value.
Analyze Cost Contributions¶
# Access the cost contributions from the results
annual = results_ch.postprocessing['df_annual']
# Filter costs related to the new technology
annual.loc['Newtech']
C_inv | C_maint | Annual_Prod | F_Mult | tau | C_inv_an | Category | Category_2 | Sector | |
---|---|---|---|---|---|---|---|---|---|
Run | |||||||||
0 | 1.827272e-07 | 0.000731 | 0.028976 | 0.000018 | 0.045981 | 8.401919e-09 | Others | Others | Others |
- This allows you to see the investment, maintenance, and operational costs associated with
Newtech
.
Conclusion¶
By following these steps, you have successfully added a new technology to the EnergyScope model, integrated it into the existing infrastructure, and solved the model to evaluate its performance. The generated .dat
file contains all the necessary parameters for the new technology, and the model incorporates this data during the optimization process.
This process enables you to:
- Expand the Model: Include emerging or hypothetical technologies to explore their potential impact.
- Customize Analyses: Tailor the energy system model to specific scenarios or research questions.
- Enhance Decision-Making: Provide insights into how new technologies could be integrated into future energy systems.
Remember to:
- Validate Parameters: Ensure that the parameters for the new technology are realistic and consistent with the rest of the model.
- Check Model Compatibility: Verify that the technology interacts appropriately with existing layers and sets in the model.
- Interpret Results Carefully: Consider how the addition of the new technology affects the overall system, including costs, emissions, and energy flows.
By mastering the addition of new technologies, you can make the EnergyScope model a powerful tool for exploring a wide range of energy system configurations and strategies.