{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Workflow for a 1node energy system\n",
    "\n",
    "In this application of the FINE framework, a multi-regional energy system is modeled and optimized.\n",
    "\n",
    "All classes which are available to the user are utilized and examples of the selection of different parameters within these classes are given.\n",
    "\n",
    "The workflow is structures as follows:\n",
    "1. Required packages are imported and the input data path is set\n",
    "2. An energy system model instance is created\n",
    "3. Commodity sources are added to the energy system model\n",
    "4. Commodity conversion components are added to the energy system model\n",
    "5. Commodity storages are added to the energy system model\n",
    "7. Commodity sinks are added to the energy system model\n",
    "8. The energy system model is optimized\n",
    "9. Selected optimization results are presented\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 1. Import required packages and set input data path\n",
    "\n",
    "The FINE framework is imported which provides the required classes and functions for modeling the energy system."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "import FINE as fn\n",
    "from getData import getData\n",
    "#import pandas as pd\n",
    "import os\n",
    "cwd = os.getcwd()\n",
    "data = getData()\n",
    "\n",
    "%matplotlib inline  \n",
    "%load_ext autoreload\n",
    "%autoreload 2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 2. Create an energy system model instance \n",
    "\n",
    "The structure of the energy system model is given by the considered locations, commodities, the number of time steps as well as the hours per time step.\n",
    "\n",
    "The commodities are specified by a unit (i.e. 'GW_electric', 'GW_H2lowerHeatingValue', 'Mio. t CO2/h') which can be given as an energy or mass unit per hour. Furthermore, the cost unit and length unit are specified."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "locations = {'GermanyRegion'}\n",
    "commodityUnitDict = {'electricity': r'GW$_{el}$', 'hydrogen': r'GW$_{H_{2},LHV}$'}\n",
    "commodities = {'electricity', 'hydrogen'}\n",
    "numberOfTimeSteps=8760\n",
    "hoursPerTimeStep=1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "esM = fn.EnergySystemModel(locations=locations, commodities=commodities, numberOfTimeSteps=8760,\n",
    "                           commodityUnitsDict=commodityUnitDict,\n",
    "                           hoursPerTimeStep=1, costUnit='1e9 Euro', lengthUnit='km', verboseLogLevel=0)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 3. Add commodity sources to the energy system model"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3.1. Electricity sources"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Wind onshore"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "esM.add(fn.Source(esM=esM, name='Wind (onshore)', commodity='electricity', hasCapacityVariable=True,\n",
    "                  operationRateMax=data['Wind (onshore), operationRateMax'],\n",
    "                  capacityMax=data['Wind (onshore), capacityMax'],\n",
    "                  investPerCapacity=1.1, opexPerCapacity=1.1*0.02, interestRate=0.08,\n",
    "                  economicLifetime=20))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Full load hours:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2300.4069071646272"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['Wind (onshore), operationRateMax'].sum()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 4. Add conversion components to the energy system model"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### New combined cycly gas turbines for hydrogen"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "esM.add(fn.Conversion(esM=esM, name='New CCGT plants (hydrogen)', physicalUnit=r'GW$_{el}$',\n",
    "                      commodityConversionFactors={'electricity':1, 'hydrogen':-1/0.6},\n",
    "                      hasCapacityVariable=True, \n",
    "                      investPerCapacity=0.7, opexPerCapacity=0.021, interestRate=0.08,\n",
    "                      economicLifetime=33))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Electrolyzers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "esM.add(fn.Conversion(esM=esM, name='Electroylzers', physicalUnit=r'GW$_{el}$',\n",
    "                      commodityConversionFactors={'electricity':-1, 'hydrogen':0.7},\n",
    "                      hasCapacityVariable=True, \n",
    "                      investPerCapacity=0.5, opexPerCapacity=0.5*0.025, interestRate=0.08,\n",
    "                      economicLifetime=10))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 5. Add commodity storages to the energy system model"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 5.1. Electricity storage"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Lithium ion batteries\n",
    "\n",
    "The self discharge of a lithium ion battery is here described as 3% per month. The self discharge per hours is obtained using the equation (1-$\\text{selfDischarge}_\\text{hour})^{30*24\\text{h}} = 1-\\text{selfDischarge}_\\text{month}$."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "esM.add(fn.Storage(esM=esM, name='Li-ion batteries', commodity='electricity',\n",
    "                   hasCapacityVariable=True, chargeEfficiency=0.95,\n",
    "                   cyclicLifetime=10000, dischargeEfficiency=0.95, selfDischarge=1-(1-0.03)**(1/(30*24)),\n",
    "                   chargeRate=1, dischargeRate=1, doPreciseTsaModeling=False,\n",
    "                   investPerCapacity=0.151, opexPerCapacity=0.002, interestRate=0.08,\n",
    "                   economicLifetime=22))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 5.2. Hydrogen storage"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Hydrogen filled salt caverns\n",
    "The maximum capacity is here obtained by: dividing the given capacity (which is given for methane) by the lower heating value of methane and then multiplying it with the lower heating value of hydrogen."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "esM.add(fn.Storage(esM=esM, name='Salt caverns (hydrogen)', commodity='hydrogen',\n",
    "                   hasCapacityVariable=True, capacityVariableDomain='continuous',\n",
    "                   capacityPerPlantUnit=133,\n",
    "                   chargeRate=1/470.37, dischargeRate=1/470.37, sharedPotentialID='Existing salt caverns',\n",
    "                   stateOfChargeMin=0.33, stateOfChargeMax=1, capacityMax=data['Salt caverns (hydrogen), capacityMax'],\n",
    "                   investPerCapacity=0.00011, opexPerCapacity=0.00057, interestRate=0.08,\n",
    "                   economicLifetime=30))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 7. Add commodity sinks to the energy system model"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.1. Electricity sinks"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Electricity demand"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "esM.add(fn.Sink(esM=esM, name='Electricity demand', commodity='electricity',\n",
    "                hasCapacityVariable=False, operationRateFix=data['Electricity demand, operationRateFix']))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.2. Hydrogen sinks"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Fuel cell electric vehicle (FCEV) demand"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "FCEV_penetration=0.5\n",
    "esM.add(fn.Sink(esM=esM, name='Hydrogen demand', commodity='hydrogen', hasCapacityVariable=False,\n",
    "                operationRateFix=data['Hydrogen demand, operationRateFix']*FCEV_penetration))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 8. Optimize energy system model"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "All components are now added to the model and the model can be optimized. If the computational complexity of the optimization should be reduced, the time series data of the specified components can be clustered before the optimization and the parameter timeSeriesAggregation is set to True in the optimize call."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Clustering time series data with 30 typical periods and 24 time steps per period...\n",
      "\t\t(0.5624 sec)\n",
      "\n"
     ]
    }
   ],
   "source": [
    "esM.cluster(numberOfTypicalPeriods=30)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Time series aggregation specifications:\n",
      "Number of typical periods:30, number of time steps per periods:24\n",
      "\n",
      "Declaring sets, variables and constraints for SourceSinkModel\n",
      "\tdeclaring sets... \n",
      "\tdeclaring variables... \n",
      "\tdeclaring constraints... \n",
      "\t\t(0.7655 sec)\n",
      "\n",
      "Declaring sets, variables and constraints for ConversionModel\n",
      "\tdeclaring sets... \n",
      "\tdeclaring variables... \n",
      "\tdeclaring constraints... \n",
      "\t\t(0.0469 sec)\n",
      "\n",
      "Declaring sets, variables and constraints for StorageModel\n",
      "\tdeclaring sets... \n",
      "\tdeclaring variables... \n",
      "\tdeclaring constraints... \n",
      "\t\t(0.3125 sec)\n",
      "\n",
      "Declaring shared potential constraint...\n",
      "\t\t(0.0000 sec)\n",
      "\n",
      "Declaring commodity balances...\n",
      "\t\t(0.1250 sec)\n",
      "\n",
      "Declaring objective function...\n",
      "\t\t(0.0313 sec)\n",
      "\n",
      "GLPSOL: GLPK LP/MIP Solver, v4.65\n",
      "Parameter(s) specified in the command line:\n",
      " --write C:\\Users\\T58C8~1.GRO\\AppData\\Local\\Temp\\tmpdk70dnrl.glpk.raw --wglp\n",
      " C:\\Users\\T58C8~1.GRO\\AppData\\Local\\Temp\\tmp3wh6rgo1.glpk.glp --cpxlp C:\\Users\\T58C8~1.GRO\\AppData\\Local\\Temp\\tmpbaf5x4m8.pyomo.lp\n",
      "Reading problem data from 'C:\\Users\\T58C8~1.GRO\\AppData\\Local\\Temp\\tmpbaf5x4m8.pyomo.lp'...\n",
      "14500 rows, 8843 columns, 37962 non-zeros\n",
      "90317 lines were read\n",
      "Writing problem data to 'C:\\Users\\T58C8~1.GRO\\AppData\\Local\\Temp\\tmp3wh6rgo1.glpk.glp'...\n",
      "73758 lines were written\n",
      "GLPK Simplex Optimizer, v4.65\n",
      "14500 rows, 8843 columns, 37962 non-zeros\n",
      "Preprocessing...\n",
      "12873 rows, 7337 columns, 34710 non-zeros\n",
      "Scaling...\n",
      " A: min|aij| =  2.126e-03  max|aij| =  4.545e+02  ratio =  2.138e+05\n",
      "GM: min|aij| =  2.576e-01  max|aij| =  3.883e+00  ratio =  1.508e+01\n",
      "EQ: min|aij| =  6.633e-02  max|aij| =  1.000e+00  ratio =  1.508e+01\n",
      "Constructing initial basis...\n",
      "Size of triangular part is 12841\n",
      "      0: obj =   0.000000000e+00 inf =   1.164e+04 (2160)\n",
      "Perturbing LP to avoid stalling [1813]...\n",
      "   4177: obj =   1.666566865e+01 inf =   1.362e-05 (0) 40\n",
      "Removing LP perturbation [6352]...\n",
      "*  6352: obj =   9.659038230e+00 inf =   5.917e-14 (0) 21\n",
      "OPTIMAL LP SOLUTION FOUND\n",
      "Time used:   3.0 secs\n",
      "Memory used: 16.6 Mb (17442327 bytes)\n",
      "Writing basic solution to 'C:\\Users\\T58C8~1.GRO\\AppData\\Local\\Temp\\tmpdk70dnrl.glpk.raw'...\n",
      "23352 lines were written\n",
      "\n",
      "Status: ok\n",
      "Termination condition: optimal\n",
      "Statistics: \n",
      "  Branch and bound: \n",
      "    Number of bounded subproblems: 0\n",
      "    Number of created subproblems: 0\n",
      "Error rc: 0\n",
      "Time: 3.2494983673095703\n",
      "\n",
      "\n",
      "Name: unknown\n",
      "Lower bound: 9.65903822999387\n",
      "Upper bound: 9.65903822999387\n",
      "Number of objectives: 1\n",
      "Number of constraints: 14500\n",
      "Number of variables: 8843\n",
      "Number of nonzeros: 37962\n",
      "Sense: minimize\n",
      "\n",
      "Solve time: 4.046280145645142 sec.\n",
      "\n",
      "Processing optimization output...\n",
      "for SourceSinkModel ...(0.4530sec)\n",
      "for ConversionModel ...(0.4531sec)\n",
      "for StorageModel ...  (1.9372sec)\n",
      "\t\t(2.8433 sec)\n",
      "\n"
     ]
    }
   ],
   "source": [
    "esM.optimize(timeSeriesAggregation=True, solver='glpk')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 9. Selected results output"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Sources and Sink\n",
    "\n",
    "Show optimization summary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>GermanyRegion</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Component</th>\n",
       "      <th>Property</th>\n",
       "      <th>Unit</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Electricity demand</th>\n",
       "      <th>operation</th>\n",
       "      <th>[GW$_{el}$*h/a]</th>\n",
       "      <td>30957.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Hydrogen demand</th>\n",
       "      <th>operation</th>\n",
       "      <th>[GW$_{H_{2},LHV}$*h/a]</th>\n",
       "      <td>4765.07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"6\" valign=\"top\">Wind (onshore)</th>\n",
       "      <th>TAC</th>\n",
       "      <th>[1e9 Euro/a]</th>\n",
       "      <td>5.77465</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>capacity</th>\n",
       "      <th>[GW$_{el}$]</th>\n",
       "      <td>43.0824</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>capexCap</th>\n",
       "      <th>[1e9 Euro/a]</th>\n",
       "      <td>4.82684</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>invest</th>\n",
       "      <th>[1e9 Euro]</th>\n",
       "      <td>47.3906</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>operation</th>\n",
       "      <th>[GW$_{el}$*h/a]</th>\n",
       "      <td>43469.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>opexCap</th>\n",
       "      <th>[1e9 Euro/a]</th>\n",
       "      <td>0.947812</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                    GermanyRegion\n",
       "Component          Property  Unit                                \n",
       "Electricity demand operation [GW$_{el}$*h/a]              30957.9\n",
       "Hydrogen demand    operation [GW$_{H_{2},LHV}$*h/a]       4765.07\n",
       "Wind (onshore)     TAC       [1e9 Euro/a]                 5.77465\n",
       "                   capacity  [GW$_{el}$]                  43.0824\n",
       "                   capexCap  [1e9 Euro/a]                 4.82684\n",
       "                   invest    [1e9 Euro]                   47.3906\n",
       "                   operation [GW$_{el}$*h/a]              43469.5\n",
       "                   opexCap   [1e9 Euro/a]                0.947812"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "esM.getOptimizationSummary(\"SourceSinkModel\", outputLevel=2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Plot operation time series (either one or two dimensional)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 55816 characters]\n",
      "text/plain": [
       "<Figure size 864x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, ax = fn.plotOperation(esM, 'Electricity demand', 'GermanyRegion')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 35596 characters]\n",
      "text/plain": [
       "<Figure size 864x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, ax = fn.plotOperationColorMap(esM, 'Electricity demand', 'GermanyRegion')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Conversion\n",
    "\n",
    "Show optimization summary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>GermanyRegion</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Component</th>\n",
       "      <th>Property</th>\n",
       "      <th>Unit</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"6\" valign=\"top\">Electroylzers</th>\n",
       "      <th>TAC</th>\n",
       "      <th>[1e9 Euro/a]</th>\n",
       "      <td>0.354699</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>capacity</th>\n",
       "      <th>[GW$_{el}$]</th>\n",
       "      <td>4.07631</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>capexCap</th>\n",
       "      <th>[1e9 Euro/a]</th>\n",
       "      <td>0.303745</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>invest</th>\n",
       "      <th>[1e9 Euro]</th>\n",
       "      <td>2.03816</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>operation</th>\n",
       "      <th>[GW$_{el}$*h/a]</th>\n",
       "      <td>15353.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>opexCap</th>\n",
       "      <th>[1e9 Euro/a]</th>\n",
       "      <td>0.0509539</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"6\" valign=\"top\">New CCGT plants (hydrogen)</th>\n",
       "      <th>TAC</th>\n",
       "      <th>[1e9 Euro/a]</th>\n",
       "      <td>0.126157</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>capacity</th>\n",
       "      <th>[GW$_{el}$]</th>\n",
       "      <td>1.54233</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>capexCap</th>\n",
       "      <th>[1e9 Euro/a]</th>\n",
       "      <td>0.0937679</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>invest</th>\n",
       "      <th>[1e9 Euro]</th>\n",
       "      <td>1.07963</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>operation</th>\n",
       "      <th>[GW$_{el}$*h/a]</th>\n",
       "      <td>3589.34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>opexCap</th>\n",
       "      <th>[1e9 Euro/a]</th>\n",
       "      <td>0.032389</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                     GermanyRegion\n",
       "Component                  Property  Unit                         \n",
       "Electroylzers              TAC       [1e9 Euro/a]         0.354699\n",
       "                           capacity  [GW$_{el}$]           4.07631\n",
       "                           capexCap  [1e9 Euro/a]         0.303745\n",
       "                           invest    [1e9 Euro]            2.03816\n",
       "                           operation [GW$_{el}$*h/a]       15353.3\n",
       "                           opexCap   [1e9 Euro/a]        0.0509539\n",
       "New CCGT plants (hydrogen) TAC       [1e9 Euro/a]         0.126157\n",
       "                           capacity  [GW$_{el}$]           1.54233\n",
       "                           capexCap  [1e9 Euro/a]        0.0937679\n",
       "                           invest    [1e9 Euro]            1.07963\n",
       "                           operation [GW$_{el}$*h/a]       3589.34\n",
       "                           opexCap   [1e9 Euro/a]         0.032389"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "esM.getOptimizationSummary(\"ConversionModel\", outputLevel=2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 21736 characters]\n",
      "text/plain": [
       "<Figure size 864x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, ax = fn.plotOperationColorMap(esM, 'New CCGT plants (hydrogen)', 'GermanyRegion')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Storage\n",
    "\n",
    "Show optimization summary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>GermanyRegion</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Component</th>\n",
       "      <th>Property</th>\n",
       "      <th>Unit</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"7\" valign=\"top\">Li-ion batteries</th>\n",
       "      <th>TAC</th>\n",
       "      <th>[1e9 Euro/a]</th>\n",
       "      <td>2.68739</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>capacity</th>\n",
       "      <th>[GW$_{el}$*h]</th>\n",
       "      <td>159.937</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>capexCap</th>\n",
       "      <th>[1e9 Euro/a]</th>\n",
       "      <td>2.36752</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>invest</th>\n",
       "      <th>[1e9 Euro]</th>\n",
       "      <td>24.1504</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>operationCharge</th>\n",
       "      <th>[GW$_{el}$*h/a]</th>\n",
       "      <td>7371.12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>operationDischarge</th>\n",
       "      <th>[GW$_{el}$*h/a]</th>\n",
       "      <td>6623.48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>opexCap</th>\n",
       "      <th>[1e9 Euro/a]</th>\n",
       "      <td>0.319873</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"7\" valign=\"top\">Salt caverns (hydrogen)</th>\n",
       "      <th>TAC</th>\n",
       "      <th>[1e9 Euro/a]</th>\n",
       "      <td>0.716143</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>capacity</th>\n",
       "      <th>[GW$_{H_{2},LHV}$*h]</th>\n",
       "      <td>1235.22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>capexCap</th>\n",
       "      <th>[1e9 Euro/a]</th>\n",
       "      <td>0.0120693</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>invest</th>\n",
       "      <th>[1e9 Euro]</th>\n",
       "      <td>0.135874</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>operationCharge</th>\n",
       "      <th>[GW$_{H_{2},LHV}$*h/a]</th>\n",
       "      <td>10243.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>operationDischarge</th>\n",
       "      <th>[GW$_{H_{2},LHV}$*h/a]</th>\n",
       "      <td>10243.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>opexCap</th>\n",
       "      <th>[1e9 Euro/a]</th>\n",
       "      <td>0.704073</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                                  GermanyRegion\n",
       "Component               Property           Unit                                \n",
       "Li-ion batteries        TAC                [1e9 Euro/a]                 2.68739\n",
       "                        capacity           [GW$_{el}$*h]                159.937\n",
       "                        capexCap           [1e9 Euro/a]                 2.36752\n",
       "                        invest             [1e9 Euro]                   24.1504\n",
       "                        operationCharge    [GW$_{el}$*h/a]              7371.12\n",
       "                        operationDischarge [GW$_{el}$*h/a]              6623.48\n",
       "                        opexCap            [1e9 Euro/a]                0.319873\n",
       "Salt caverns (hydrogen) TAC                [1e9 Euro/a]                0.716143\n",
       "                        capacity           [GW$_{H_{2},LHV}$*h]         1235.22\n",
       "                        capexCap           [1e9 Euro/a]               0.0120693\n",
       "                        invest             [1e9 Euro]                  0.135874\n",
       "                        operationCharge    [GW$_{H_{2},LHV}$*h/a]       10243.7\n",
       "                        operationDischarge [GW$_{H_{2},LHV}$*h/a]       10243.7\n",
       "                        opexCap            [1e9 Euro/a]                0.704073"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "esM.getOptimizationSummary(\"StorageModel\", outputLevel=2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 36492 characters]\n",
      "text/plain": [
       "<Figure size 864x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, ax = fn.plotOperationColorMap(esM, 'Li-ion batteries', 'GermanyRegion', \n",
    "                                   variableName='stateOfChargeOperationVariablesOptimum')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 26792 characters]\n",
      "text/plain": [
       "<Figure size 864x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, ax = fn.plotOperationColorMap(esM, 'Salt caverns (hydrogen)', 'GermanyRegion',\n",
    "                                  variableName='stateOfChargeOperationVariablesOptimum')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "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.6.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
