{ "cells": [ { "cell_type": "markdown", "id": "7132b353", "metadata": {}, "source": [ "# Add a New Technology\n", "\n", "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.\n", "\n", "## Step-by-Step Instructions\n", "\n", "To add a new technology, follow these steps:\n", "\n", "### 1. Set Up Your Project Environment\n", "\n", "Ensure that your project directory is properly structured and contains the necessary files and folders. Your project should look like this:\n", "\n", "```\n", "your_project/\n", "├── output/ # This folder will contain the .dat file for the new technology\n", "├── your_script.py # The script where you will add the new technology\n", "```\n", "\n", "- **`output/`**: Directory where the generated `.dat` file for the new technology will be saved.\n", "- **`your_script.py`**: Python script where you will write the code to add the new technology.\n", "\n", "### 2. Import Necessary Libraries and Initialize the Model\n", "\n", "First, import the required classes and functions from the `energyscope` package and initialize the existing model (e.g., `infrastructure`)." ] }, { "cell_type": "code", "id": "11ec8b99", "metadata": { "ExecuteTime": { "end_time": "2025-01-31T17:30:35.350476Z", "start_time": "2025-01-31T17:30:35.199080Z" } }, "source": [ "from energyscope.energyscope import Energyscope\n", "from energyscope.result import postprocessing\n", "from energyscope.plots import plot_sankey\n", "from energyscope.models import infrastructure_ch_2050\n", "\n", "# Initialize the EnergyScope model with the 'infrastructure' dataset\n", "es_infra_ch = Energyscope(model=infrastructure_ch_2050)" ], "outputs": [], "execution_count": 1 }, { "cell_type": "markdown", "id": "349fbf5f", "metadata": {}, "source": [ "\n", "\n", "- **`Energyscope`**: Main class to interact with the EnergyScope model.\n", "- **`postprocessing`**: Function to process results after the model run.\n", "- **`plot_sankey`**: Function to generate a Sankey diagram for visualization.\n", "- **`infrastructure`**: Predefined model configuration focusing on energy infrastructure.\n", "\n", "### 3. Define the New Technology Parameters\n", "\n", "Next, define a dictionary containing all the necessary parameters for your new technology. These parameters include technical, economic, and environmental attributes." ] }, { "cell_type": "code", "id": "e3efa2aa", "metadata": { "ExecuteTime": { "end_time": "2025-01-31T17:30:35.353849Z", "start_time": "2025-01-31T17:30:35.351139Z" } }, "source": [ "# Define the parameters for the new technology\n", "name = 'Newtech'\n", "new_tech_params = {\n", " 'name': name,\n", " 'c_inv': 0.01, # Investment cost (MCHF/GW)\n", " 'c_maint': 40, # Maintenance cost (MCHF/GW)\n", " 'gwp_constr': 3900, # Greenhouse gas emissions (ktCO2eq/GW)\n", " 'lifetime': 30, # Lifetime of the technology (years)\n", " 'c_p': 1, # Capacity factor (%)\n", " 'fmin_perc': 0, # Minimum % of production for its sector (%)\n", " 'fmax_perc': 1, # Maximum % of production for its sector (%)\n", " 'f_min': 0, # Minimum installed capacity (GW)\n", " 'f_max': 20, # Maximum installed capacity (GW)\n", " 'c_p_t': { # Variable capacity factor (%) per time step\n", " 1: 0.0848,\n", " 2: 0.1504,\n", " 3: 0.1920,\n", " 4: 0.2448,\n", " 5: 0.2496,\n", " 6: 0.2512,\n", " 7: 0.2624,\n", " 8: 0.2496,\n", " 9: 0.2048,\n", " 10: 0.1408,\n", " 11: 0.0832,\n", " 12: 0.0576\n", " },\n", " 'layers_in_out': { # Input and output layers with their coefficients\n", " 'ELECTRICITY_MV': 0.5,\n", " 'HEAT_LOW_T_DHN': 1,\n", " 'WOOD': -1\n", " },\n", " 'tech_sets': { # Sets to which the technology belongs\n", " 'TECHNOLOGIES_OF_END_USES_TYPE': ['HEAT_LOW_T_DHN', 'ELECTRICITY_MV']\n", " }\n", "}" ], "outputs": [], "execution_count": 2 }, { "cell_type": "markdown", "id": "819fe1be", "metadata": {}, "source": [ "\n", "\n", "- **Key Parameters**:\n", " - **`name`**: Unique identifier for the technology.\n", " - **`c_inv`**: Investment cost per GW.\n", " - **`c_maint`**: Annual maintenance cost per GW.\n", " - **`gwp_constr`**: Greenhouse gas emissions associated per GW installed.\n", " - **`lifetime`**: Expected operational lifetime.\n", " - **`c_p`**: Capacity factor.\n", " - **`fmin_perc`**, **`fmax_perc`**: Minimum and maximum % of production for its sector.\n", " - **`f_min`**, **`f_max`**: Minimum and maximum installed capacity in GW.\n", " - **`c_p_t`**: Variable capacity factor (%) per time step (e.g., months).\n", " - **`layers_in_out`**: Defines the input and output flows between layers, with positive values for outputs and negative for inputs.\n", " - **`tech_sets`**: Specifies the sets or categories the technology belongs to, which affects how it interacts with other model components.\n", "\n", "### 4. Add the New Technology to the Model\n", "\n", "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." ] }, { "cell_type": "code", "id": "ffb43c3c", "metadata": { "ExecuteTime": { "end_time": "2025-01-31T17:30:35.357003Z", "start_time": "2025-01-31T17:30:35.354521Z" } }, "source": [ "# Add the new technology and save the .dat file in the output folder\n", "es_infra_ch.add_technology(tech_parameters=new_tech_params, output_dir=\"./tutorial_output\")" ], "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ref_size is not defined, default value: 0.001 will be used.\n", "trl is not defined, default value: 9 will be used.\n", "Technology 'Newtech' successfully added and saved in ./tutorial_output/Newtech.dat\n" ] } ], "execution_count": 3 }, { "cell_type": "markdown", "id": "c9ed8d04", "metadata": {}, "source": [ "\n", "\n", "- **`tech_parameters`**: The dictionary containing your new technology's parameters.\n", "- **`output_dir`**: Directory where the generated `.dat` file will be saved.\n", "\n", "> **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.\n", "\n", "### 5. Solve the Model with the New Technology\n", "\n", "Now that the new technology is added, solve the model to see how the inclusion of the new technology affects the energy system configuration." ] }, { "cell_type": "code", "id": "7815b6e6", "metadata": { "ExecuteTime": { "end_time": "2025-01-31T17:30:36.545648Z", "start_time": "2025-01-31T17:30:35.357625Z" } }, "source": [ "# Solve the model\n", "results_ch = es_infra_ch.calc()" ], "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Gurobi 11.0.3: Gurobi 11.0.3: optimal solution; objective 8718.762889\n", "9397 simplex iterations\n", "1 branching node\n" ] } ], "execution_count": 4 }, { "cell_type": "markdown", "id": "0deda899", "metadata": {}, "source": [ "\n", "\n", "- **`results_ch`**: This variable stores the results of the model run, including variables, parameters, and other outputs.\n", "\n", "> **Note**: The computation time may vary depending on the complexity of the model and the capabilities of your system.\n", "\n", "### 6. Post-Process and Visualize the Results\n", "\n", "After solving the model, you can analyze the results by post-processing and visualizing them.\n", "\n", "#### Post-Process the Results" ] }, { "cell_type": "code", "id": "552dc6cb", "metadata": { "ExecuteTime": { "end_time": "2025-01-31T17:30:36.566450Z", "start_time": "2025-01-31T17:30:36.546401Z" } }, "source": [ "# Post-process the results to compute KPIs and prepare for visualization\n", "results_ch = postprocessing(results_ch)" ], "outputs": [], "execution_count": 5 }, { "cell_type": "markdown", "id": "9c56d84b", "metadata": {}, "source": [ "\n", "\n", "- The `postprocessing` function enriches the results with additional analysis, making them ready for interpretation and plotting.\n", "\n", "#### Generate and Display a Sankey Diagram\n", "\n", "A Sankey diagram visually represents the energy flows within the system, showing how the new technology interacts with other components." ] }, { "cell_type": "code", "id": "ac22015b", "metadata": { "ExecuteTime": { "end_time": "2025-01-31T17:30:36.819335Z", "start_time": "2025-01-31T17:30:36.567094Z" } }, "source": [ "# Generate the Sankey diagram based on the results\n", "fig = plot_sankey(results_ch)\n", "fig.show()" ], "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.plotly.v1+json": { "data": [ { "link": { "color": [ "rgba(181, 31, 31, 0.50)", "rgba(181, 31, 31, 0.50)", "rgba(181, 31, 31, 0.50)", "rgba(181, 31, 31, 0.50)", "rgba(181, 31, 31, 0.50)", "rgba(181, 31, 31, 0.50)", "rgba(255, 225, 0, 0.50)", "rgba(179, 123, 68, 0.50)", "rgba(205, 133, 63, 0.50)", "rgba(181, 31, 31, 0.50)", "rgba(181, 31, 31, 0.50)", "rgba(181, 31, 31, 0.50)", "rgba(181, 31, 31, 0.50)", "rgba(181, 31, 31, 0.50)", "rgba(0, 0, 0, 0.50)", "rgba(0, 206, 209, 0.50)", "rgba(0, 206, 209, 0.50)", "rgba(0, 0, 0, 0.50)", "rgba(0, 0, 255, 0.50)", "rgba(250, 128, 114, 0.50)", "rgba(250, 128, 114, 0.50)", "rgba(250, 128, 114, 0.50)", "rgba(0, 206, 209, 0.50)", "rgba(205, 133, 63, 0.50)", "rgba(0, 0, 0, 0.50)", "rgba(0, 0, 0, 0.50)", "rgba(0, 0, 0, 0.50)", "rgba(0, 0, 0, 0.50)", "rgba(0, 0, 0, 0.50)", "rgba(0, 0, 0, 0.50)", "rgba(0, 191, 255, 0.50)", "rgba(0, 191, 255, 0.50)", "rgba(0, 191, 255, 0.50)", "rgba(0, 191, 255, 0.50)", "rgba(0, 191, 255, 0.50)", "rgba(0, 191, 255, 0.50)", "rgba(0, 191, 255, 0.50)", "rgba(0, 191, 255, 0.50)", "rgba(0, 191, 255, 0.50)", "rgba(0, 191, 255, 0.50)", "rgba(0, 191, 255, 0.50)", "rgba(0, 191, 255, 0.50)", "rgba(0, 191, 255, 0.50)", "rgba(0, 191, 255, 0.50)", "rgba(0, 191, 255, 0.50)", "rgba(0, 191, 255, 0.50)", "rgba(0, 191, 255, 0.50)", "rgba(0, 191, 255, 0.50)", "rgba(0, 191, 255, 0.50)", "rgba(0, 191, 255, 0.50)", "rgba(0, 191, 255, 0.50)", "rgba(255, 215, 0, 0.50)", "rgba(255, 215, 0, 0.50)", "rgba(255, 225, 0, 0.50)", "rgba(255, 215, 0, 0.50)" ], "label": [ 38548.48760000001, 2950.855277048915, 18425.125983947448, 5.447640452011246E-4, 473.01561089900855, 473.01561089900855, 5284.745762711865, 12472.0, 3020.994583340589, 547.1537916062405, 1696.1745610899015, 3081.862623864128, 11636.554634338736, 3020.994583340589, 2950.855277048915, 16580.16, 16122.6096, 3606.3732, 40299.36, 6848.515122750866, 2068.484877249135, 8917.000000000002, 12472.0, 3020.994583340589, 520.5841569600001, 4239.540829999999, 1151.9683202999997, 1463.2592000000025, 2762.850849499999, 612.1907999999996, 2471.4522689992555, 11636.554634338736, 12848.210917080001, 4606.281495986862, 7.128187348770342E-5, 16580.16, 211.38983050847457, 16122.6096, 1369.5797500452186, 3606.3732, 1510.4972916702945, 5296.152796065097, 40299.36, 8895.76, 25871.84, 7403.6, 520.5841569600001, 4239.540829999999, 1151.9683202999997, 4226.110049500002, 612.1907999999996, 4726.430033756867, 558.3157289550078, 5284.745762711865, 5284.745762711865 ], "source": [ 15, 7, 15, 28, 13, 16, 18, 20, 21, 0, 0, 4, 8, 26, 29, 30, 30, 30, 31, 36, 36, 37, 38, 40, 1, 2, 5, 34, 34, 35, 3, 9, 9, 9, 9, 17, 18, 19, 4, 24, 26, 27, 39, 9, 9, 9, 9, 9, 9, 9, 9, 25, 25, 32, 33 ], "target": [ 14, 14, 14, 14, 16, 14, 32, 38, 40, 13, 13, 13, 13, 14, 7, 17, 19, 24, 39, 4, 0, 36, 18, 26, 23, 23, 23, 22, 23, 22, 9, 8, 15, 15, 6, 9, 9, 9, 9, 9, 9, 9, 9, 10, 11, 12, 1, 2, 5, 34, 35, 3, 0, 33, 25 ], "value": [ 38548.48760000001, 2950.855277048915, 18425.125983947448, 5.447640452011246E-4, 473.01561089900855, 473.01561089900855, 5284.745762711865, 12472.0, 3020.994583340589, 547.1537916062405, 1696.1745610899015, 3081.862623864128, 11636.554634338736, 3020.994583340589, 2950.855277048915, 16580.16, 16122.6096, 3606.3732, 40299.36, 6848.515122750866, 2068.484877249135, 8917.000000000002, 12472.0, 3020.994583340589, 520.5841569600001, 4239.540829999999, 1151.9683202999997, 1463.2592000000025, 2762.850849499999, 612.1907999999996, 2471.4522689992555, 11636.554634338736, 12848.210917080001, 4606.281495986862, 7.128187348770342E-5, 16580.16, 211.38983050847457, 16122.6096, 1369.5797500452186, 3606.3732, 1510.4972916702945, 5296.152796065097, 40299.36, 8895.76, 25871.84, 7403.6, 520.5841569600001, 4239.540829999999, 1151.9683202999997, 4226.110049500002, 612.1907999999996, 4726.430033756867, 558.3157289550078, 5284.745762711865, 5284.745762711865 ] }, "node": { "color": "#DCDCDC", "label": [ "BOILER", "BUS", "CAR", "CCGT_CC", "COGEN", "COMMUTER", "DEEP_SALINE", "DHN_DEEP_GEO", "DIRECT_ELEC", "ELECTRICITY", "EUD_ELECTRICITY_HV", "EUD_ELECTRICITY_LV", "EUD_ELECTRICITY_MV", "HEAT_HIGH_T", "HEAT_LOW_T", "HP", "HT_LT", "HYDRO_DAM", "HYDRO_GAS", "HYDRO_RIVER", "IMP_WET_BIOMASS", "IMP_WOOD", "MOBILITY", "MOBILITY_PASSENGER", "NEW_HYDRO_RIVER", "NG", "Newtech", "PV", "RENOVATION", "RES_GEO", "RES_HYDRO", "RES_WIND", "SNG", "SNG_NG", "TRAIN", "TRUCK", "WASTE", "WASTE_BIO", "WET_BIOMASS", "WIND", "WOOD" ], "line": { "color": "black", "width": 0.5 }, "pad": 15, "thickness": 15 }, "valueformat": ".0f", "valuesuffix": "", "type": "sankey" } ], "layout": { "template": { "data": { "histogram2dcontour": [ { "type": "histogram2dcontour", "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0.0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1.0, "#f0f921" ] ] } ], "choropleth": [ { "type": "choropleth", "colorbar": { "outlinewidth": 0, "ticks": "" } } ], "histogram2d": [ { "type": "histogram2d", "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0.0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1.0, "#f0f921" ] ] } ], "heatmap": [ { "type": "heatmap", "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0.0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1.0, "#f0f921" ] ] } ], "heatmapgl": [ { "type": "heatmapgl", "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0.0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1.0, "#f0f921" ] ] } ], "contourcarpet": [ { "type": "contourcarpet", "colorbar": { "outlinewidth": 0, "ticks": "" } } ], "contour": [ { "type": "contour", "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0.0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1.0, "#f0f921" ] ] } ], "surface": [ { "type": "surface", "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0.0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1.0, "#f0f921" ] ] } ], "mesh3d": [ { "type": "mesh3d", "colorbar": { "outlinewidth": 0, "ticks": "" } } ], "scatter": [ { "fillpattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 }, "type": "scatter" } ], "parcoords": [ { "type": "parcoords", "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } } } ], "scatterpolargl": [ { "type": "scatterpolargl", "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } } } ], "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "bar" } ], "scattergeo": [ { "type": "scattergeo", "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } } } ], "scatterpolar": [ { "type": "scatterpolar", "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } } } ], "histogram": [ { "marker": { "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "histogram" } ], "scattergl": [ { "type": "scattergl", "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } } } ], "scatter3d": [ { "type": "scatter3d", "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } } } ], "scattermapbox": [ { "type": "scattermapbox", "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } } } ], "scatterternary": [ { "type": "scatterternary", "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } } } ], "scattercarpet": [ { "type": "scattercarpet", "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } } } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "barpolar" } ], "pie": [ { "automargin": true, "type": "pie" } ] }, "layout": { "autotypenumbers": "strict", "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "hovermode": "closest", "hoverlabel": { "align": "left" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "bgcolor": "#E5ECF6", "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "ternary": { "bgcolor": "#E5ECF6", "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "sequential": [ [ 0.0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1.0, "#f0f921" ] ], "sequentialminus": [ [ 0.0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1.0, "#f0f921" ] ], "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ] }, "xaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "automargin": true, "zerolinewidth": 2 }, "yaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "automargin": true, "zerolinewidth": 2 }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white", "gridwidth": 2 }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white", "gridwidth": 2 }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white", "gridwidth": 2 } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "geo": { "bgcolor": "white", "landcolor": "#E5ECF6", "subunitcolor": "white", "showland": true, "showlakes": true, "lakecolor": "white" }, "title": { "x": 0.05 }, "mapbox": { "style": "light" } } }, "title": { "text": "Sankey Diagram" }, "font": { "size": 10, "color": "black" } }, "config": { "plotlyServerURL": "https://plot.ly" } }, "text/html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "execution_count": 6 }, { "cell_type": "markdown", "id": "e0257958", "metadata": {}, "source": [ "\n", "\n", "- **`fig`**: The figure object containing the Sankey diagram.\n", "- **`fig.show()`**: Displays the diagram within the notebook or interactive environment.\n", "\n", "> **Optional**: You can save the Sankey diagram as an image or HTML file for external use." ] }, { "cell_type": "code", "id": "11a68f25", "metadata": {}, "source": [ "# Save the Sankey diagram as an image\n", "# fig.write_image('output/sankey_newtech.png')\n", "\n", "# Save the Sankey diagram as an HTML file\n", "# fig.write_html('output/sankey_newtech.html')" ], "outputs": [], "execution_count": 7 }, { "cell_type": "markdown", "id": "f82d1528", "metadata": {}, "source": [ "\n", "\n", "### 7. Verify the Integration of the New Technology\n", "\n", "To ensure that the new technology has been successfully integrated into the model, you can check the results for the presence and performance of `Newtech`.\n", "\n", "#### Check Technology Capacities\n" ] }, { "cell_type": "code", "id": "29955601", "metadata": {}, "source": [ "# Access the capacities of technologies from the results\n", "tech_capacities = results_ch.variables['F_Mult']\n", "\n", "# Display the capacity of the new technology\n", "tech_capacities.loc['Newtech']" ], "outputs": [ { "data": { "text/plain": [ "F_Mult 1.918027\n", "Run 0.000000\n", "Name: Newtech, dtype: float64" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "execution_count": 8 }, { "cell_type": "markdown", "id": "bf4a6f69", "metadata": {}, "source": [ "\n", "\n", "- **`F_Mult`**: Represents the capacities or flow multipliers of technologies.\n", "- This step verifies whether `Newtech` appears in the results and provides its capacity value.\n", "\n", "#### Analyze Cost Contributions\n" ] }, { "cell_type": "code", "id": "10740cab", "metadata": {}, "source": [ "# Access the cost contributions from the results\n", "annual = results_ch.postprocessing['df_annual']\n", "\n", "# Filter costs related to the new technology\n", "annual.loc['Newtech']" ], "outputs": [ { "data": { "text/plain": [ " C_inv C_maint Annual_Prod F_Mult tau C_op C_inv_an \\\n", "Run \n", "0 0.01918 76.7211 3020.994583 1.918027 0.045981 0.0 0.000882 \n", "\n", " Annual_Use Category Category_2 Sector \n", "Run \n", "0 3020.994583 Others Others Others " ], "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
C_invC_maintAnnual_ProdF_MulttauC_opC_inv_anAnnual_UseCategoryCategory_2Sector
Run
00.0191876.72113020.9945831.9180270.0459810.00.0008823020.994583OthersOthersOthers
\n", "
" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "execution_count": 9 }, { "cell_type": "markdown", "id": "a1ae764e", "metadata": {}, "source": [ "\n", "\n", "- This allows you to see the investment, maintenance, and operational costs associated with `Newtech`.\n", "\n", "## Conclusion\n", "\n", "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.\n", "\n", "This process enables you to:\n", "\n", "- **Expand the Model**: Include emerging or hypothetical technologies to explore their potential impact.\n", "- **Customize Analyses**: Tailor the energy system model to specific scenarios or research questions.\n", "- **Enhance Decision-Making**: Provide insights into how new technologies could be integrated into future energy systems.\n", "\n", "Remember to:\n", "\n", "- **Validate Parameters**: Ensure that the parameters for the new technology are realistic and consistent with the rest of the model.\n", "- **Check Model Compatibility**: Verify that the technology interacts appropriately with existing layers and sets in the model.\n", "- **Interpret Results Carefully**: Consider how the addition of the new technology affects the overall system, including costs, emissions, and energy flows.\n", "\n", "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.\n" ] } ], "metadata": { "kernelspec": { "display_name": ".venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.4" } }, "nbformat": 4, "nbformat_minor": 5 }