You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Mooi-Kickstart/.ipynb_checkpoints/simulation_test (1)-checkpo...

1113 lines
38 KiB
Plaintext

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

{
"cells": [
{
"cell_type": "code",
"execution_count": 73,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The autoreload extension is already loaded. To reload it, use:\n",
" %reload_ext autoreload\n"
]
}
],
"source": [
"from notepad import WaterStorage, Heatpump\n",
"\n",
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "code",
"execution_count": 74,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 75,
"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>Tsource (VDG)</th>\n",
" <th>Tsink (VDG)</th>\n",
" <th>MW (VDG)</th>\n",
" <th>Tsource (NDG)</th>\n",
" <th>Tsink (NDG)</th>\n",
" <th>MW (NDG)</th>\n",
" <th>Unnamed: 7</th>\n",
" <th>Unnamed: 8</th>\n",
" <th>Unnamed: 9</th>\n",
" <th>Unnamed: 10</th>\n",
" <th>Unnamed: 11</th>\n",
" <th>Unnamed: 12</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2018-11-01 00:00:00</th>\n",
" <td>64.986977</td>\n",
" <td>143.358798</td>\n",
" <td>0.000000</td>\n",
" <td>20.514811</td>\n",
" <td>147.621126</td>\n",
" <td>0.000000</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 00:10:00</th>\n",
" <td>64.942589</td>\n",
" <td>140.647419</td>\n",
" <td>0.000000</td>\n",
" <td>19.280056</td>\n",
" <td>147.842503</td>\n",
" <td>0.000000</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 00:20:00</th>\n",
" <td>54.578777</td>\n",
" <td>138.960493</td>\n",
" <td>0.000000</td>\n",
" <td>17.950905</td>\n",
" <td>148.138964</td>\n",
" <td>0.000000</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 00:30:00</th>\n",
" <td>65.195641</td>\n",
" <td>139.936392</td>\n",
" <td>0.000000</td>\n",
" <td>23.053127</td>\n",
" <td>147.864660</td>\n",
" <td>0.000000</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 00:40:00</th>\n",
" <td>65.137703</td>\n",
" <td>139.834265</td>\n",
" <td>0.000000</td>\n",
" <td>43.948387</td>\n",
" <td>147.306191</td>\n",
" <td>0.000000</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 15:50:00</th>\n",
" <td>64.977669</td>\n",
" <td>157.649509</td>\n",
" <td>20.631462</td>\n",
" <td>64.929398</td>\n",
" <td>166.147289</td>\n",
" <td>6.785675</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 16:00:00</th>\n",
" <td>64.951965</td>\n",
" <td>157.755094</td>\n",
" <td>20.621554</td>\n",
" <td>64.830673</td>\n",
" <td>165.059628</td>\n",
" <td>6.795409</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 16:10:00</th>\n",
" <td>64.940338</td>\n",
" <td>157.860450</td>\n",
" <td>20.594887</td>\n",
" <td>64.749290</td>\n",
" <td>164.350482</td>\n",
" <td>6.795437</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 16:20:00</th>\n",
" <td>64.940338</td>\n",
" <td>157.965580</td>\n",
" <td>20.589894</td>\n",
" <td>64.489296</td>\n",
" <td>163.434915</td>\n",
" <td>6.804813</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 16:30:00</th>\n",
" <td>64.940338</td>\n",
" <td>158.070484</td>\n",
" <td>20.799079</td>\n",
" <td>64.245148</td>\n",
" <td>163.312629</td>\n",
" <td>6.876395</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>100 rows × 12 columns</p>\n",
"</div>"
],
"text/plain": [
" Tsource (VDG) Tsink (VDG) MW (VDG) Tsource (NDG) \\\n",
"2018-11-01 00:00:00 64.986977 143.358798 0.000000 20.514811 \n",
"2018-11-01 00:10:00 64.942589 140.647419 0.000000 19.280056 \n",
"2018-11-01 00:20:00 54.578777 138.960493 0.000000 17.950905 \n",
"2018-11-01 00:30:00 65.195641 139.936392 0.000000 23.053127 \n",
"2018-11-01 00:40:00 65.137703 139.834265 0.000000 43.948387 \n",
"... ... ... ... ... \n",
"2018-11-01 15:50:00 64.977669 157.649509 20.631462 64.929398 \n",
"2018-11-01 16:00:00 64.951965 157.755094 20.621554 64.830673 \n",
"2018-11-01 16:10:00 64.940338 157.860450 20.594887 64.749290 \n",
"2018-11-01 16:20:00 64.940338 157.965580 20.589894 64.489296 \n",
"2018-11-01 16:30:00 64.940338 158.070484 20.799079 64.245148 \n",
"\n",
" Tsink (NDG) MW (NDG) Unnamed: 7 Unnamed: 8 \\\n",
"2018-11-01 00:00:00 147.621126 0.000000 NaN NaN \n",
"2018-11-01 00:10:00 147.842503 0.000000 NaN NaN \n",
"2018-11-01 00:20:00 148.138964 0.000000 NaN NaN \n",
"2018-11-01 00:30:00 147.864660 0.000000 NaN NaN \n",
"2018-11-01 00:40:00 147.306191 0.000000 NaN NaN \n",
"... ... ... ... ... \n",
"2018-11-01 15:50:00 166.147289 6.785675 NaN NaN \n",
"2018-11-01 16:00:00 165.059628 6.795409 NaN NaN \n",
"2018-11-01 16:10:00 164.350482 6.795437 NaN NaN \n",
"2018-11-01 16:20:00 163.434915 6.804813 NaN NaN \n",
"2018-11-01 16:30:00 163.312629 6.876395 NaN NaN \n",
"\n",
" Unnamed: 9 Unnamed: 10 Unnamed: 11 Unnamed: 12 \n",
"2018-11-01 00:00:00 NaN NaN NaN NaN \n",
"2018-11-01 00:10:00 NaN NaN NaN NaN \n",
"2018-11-01 00:20:00 NaN NaN NaN NaN \n",
"2018-11-01 00:30:00 NaN NaN NaN NaN \n",
"2018-11-01 00:40:00 NaN NaN NaN NaN \n",
"... ... ... ... ... \n",
"2018-11-01 15:50:00 NaN NaN NaN NaN \n",
"2018-11-01 16:00:00 NaN NaN NaN NaN \n",
"2018-11-01 16:10:00 NaN NaN NaN NaN \n",
"2018-11-01 16:20:00 NaN NaN NaN NaN \n",
"2018-11-01 16:30:00 NaN NaN NaN NaN \n",
"\n",
"[100 rows x 12 columns]"
]
},
"execution_count": 75,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data = pd.read_excel('Demand_Data_Smurfit_Preprocessed_minutely.xlsx', sheet_name='nov2018', index_col=0)\n",
"data[:100]"
]
},
{
"cell_type": "code",
"execution_count": 76,
"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>Tsource (VDG)</th>\n",
" <th>Tsink (VDG)</th>\n",
" <th>MW (VDG)</th>\n",
" <th>Tsource (NDG)</th>\n",
" <th>Tsink (NDG)</th>\n",
" <th>MW (NDG)</th>\n",
" <th>Unnamed: 7</th>\n",
" <th>Unnamed: 8</th>\n",
" <th>Unnamed: 9</th>\n",
" <th>Unnamed: 10</th>\n",
" <th>Unnamed: 11</th>\n",
" <th>Unnamed: 12</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2018-11-01 00:00:00</th>\n",
" <td>64.986977</td>\n",
" <td>143.358798</td>\n",
" <td>0.0</td>\n",
" <td>20.514811</td>\n",
" <td>147.621126</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 00:10:00</th>\n",
" <td>64.942589</td>\n",
" <td>140.647419</td>\n",
" <td>0.0</td>\n",
" <td>19.280056</td>\n",
" <td>147.842503</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 00:20:00</th>\n",
" <td>54.578777</td>\n",
" <td>138.960493</td>\n",
" <td>0.0</td>\n",
" <td>17.950905</td>\n",
" <td>148.138964</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 00:30:00</th>\n",
" <td>65.195641</td>\n",
" <td>139.936392</td>\n",
" <td>0.0</td>\n",
" <td>23.053127</td>\n",
" <td>147.864660</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 00:40:00</th>\n",
" <td>65.137703</td>\n",
" <td>139.834265</td>\n",
" <td>0.0</td>\n",
" <td>43.948387</td>\n",
" <td>147.306191</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 00:50:00</th>\n",
" <td>65.358078</td>\n",
" <td>139.731901</td>\n",
" <td>0.0</td>\n",
" <td>42.203876</td>\n",
" <td>147.547612</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 01:00:00</th>\n",
" <td>65.084549</td>\n",
" <td>139.629295</td>\n",
" <td>0.0</td>\n",
" <td>18.354761</td>\n",
" <td>148.337477</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 01:10:00</th>\n",
" <td>64.810524</td>\n",
" <td>139.526447</td>\n",
" <td>0.0</td>\n",
" <td>19.050589</td>\n",
" <td>148.183192</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 01:20:00</th>\n",
" <td>65.073433</td>\n",
" <td>139.423357</td>\n",
" <td>0.0</td>\n",
" <td>19.903652</td>\n",
" <td>149.186865</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 01:30:00</th>\n",
" <td>65.007141</td>\n",
" <td>139.320026</td>\n",
" <td>0.0</td>\n",
" <td>21.213211</td>\n",
" <td>147.764356</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Tsource (VDG) Tsink (VDG) MW (VDG) Tsource (NDG) \\\n",
"2018-11-01 00:00:00 64.986977 143.358798 0.0 20.514811 \n",
"2018-11-01 00:10:00 64.942589 140.647419 0.0 19.280056 \n",
"2018-11-01 00:20:00 54.578777 138.960493 0.0 17.950905 \n",
"2018-11-01 00:30:00 65.195641 139.936392 0.0 23.053127 \n",
"2018-11-01 00:40:00 65.137703 139.834265 0.0 43.948387 \n",
"2018-11-01 00:50:00 65.358078 139.731901 0.0 42.203876 \n",
"2018-11-01 01:00:00 65.084549 139.629295 0.0 18.354761 \n",
"2018-11-01 01:10:00 64.810524 139.526447 0.0 19.050589 \n",
"2018-11-01 01:20:00 65.073433 139.423357 0.0 19.903652 \n",
"2018-11-01 01:30:00 65.007141 139.320026 0.0 21.213211 \n",
"\n",
" Tsink (NDG) MW (NDG) Unnamed: 7 Unnamed: 8 \\\n",
"2018-11-01 00:00:00 147.621126 0.0 NaN NaN \n",
"2018-11-01 00:10:00 147.842503 0.0 NaN NaN \n",
"2018-11-01 00:20:00 148.138964 0.0 NaN NaN \n",
"2018-11-01 00:30:00 147.864660 0.0 NaN NaN \n",
"2018-11-01 00:40:00 147.306191 0.0 NaN NaN \n",
"2018-11-01 00:50:00 147.547612 0.0 NaN NaN \n",
"2018-11-01 01:00:00 148.337477 0.0 NaN NaN \n",
"2018-11-01 01:10:00 148.183192 0.0 NaN NaN \n",
"2018-11-01 01:20:00 149.186865 0.0 NaN NaN \n",
"2018-11-01 01:30:00 147.764356 0.0 NaN NaN \n",
"\n",
" Unnamed: 9 Unnamed: 10 Unnamed: 11 Unnamed: 12 \n",
"2018-11-01 00:00:00 NaN NaN NaN NaN \n",
"2018-11-01 00:10:00 NaN NaN NaN NaN \n",
"2018-11-01 00:20:00 NaN NaN NaN NaN \n",
"2018-11-01 00:30:00 NaN NaN NaN NaN \n",
"2018-11-01 00:40:00 NaN NaN NaN NaN \n",
"2018-11-01 00:50:00 NaN NaN NaN NaN \n",
"2018-11-01 01:00:00 NaN NaN NaN NaN \n",
"2018-11-01 01:10:00 NaN NaN NaN NaN \n",
"2018-11-01 01:20:00 NaN NaN NaN NaN \n",
"2018-11-01 01:30:00 NaN NaN NaN NaN "
]
},
"execution_count": 76,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"start, end = '2018-11-01 00:00:00', '2018-11-01 16:30:00'\n",
"df = data[start:end]\n",
"df[:10]\n"
]
},
{
"cell_type": "code",
"execution_count": 77,
"metadata": {},
"outputs": [],
"source": [
"df = df.resample('15T', origin=start).mean()"
]
},
{
"cell_type": "code",
"execution_count": 78,
"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>Tsource (VDG)</th>\n",
" <th>Tsink (VDG)</th>\n",
" <th>MW (VDG)</th>\n",
" <th>Tsource (NDG)</th>\n",
" <th>Tsink (NDG)</th>\n",
" <th>MW (NDG)</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2018-11-01 00:00:00</th>\n",
" <td>64.964783</td>\n",
" <td>142.003109</td>\n",
" <td>0.0</td>\n",
" <td>19.897433</td>\n",
" <td>147.731814</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 00:15:00</th>\n",
" <td>54.578777</td>\n",
" <td>138.960493</td>\n",
" <td>0.0</td>\n",
" <td>17.950905</td>\n",
" <td>148.138964</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 00:30:00</th>\n",
" <td>65.166672</td>\n",
" <td>139.885329</td>\n",
" <td>0.0</td>\n",
" <td>33.500757</td>\n",
" <td>147.585426</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 00:45:00</th>\n",
" <td>65.358078</td>\n",
" <td>139.731901</td>\n",
" <td>0.0</td>\n",
" <td>42.203876</td>\n",
" <td>147.547612</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 01:00:00</th>\n",
" <td>64.947536</td>\n",
" <td>139.577871</td>\n",
" <td>0.0</td>\n",
" <td>18.702675</td>\n",
" <td>148.260335</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Tsource (VDG) Tsink (VDG) MW (VDG) Tsource (NDG) \\\n",
"2018-11-01 00:00:00 64.964783 142.003109 0.0 19.897433 \n",
"2018-11-01 00:15:00 54.578777 138.960493 0.0 17.950905 \n",
"2018-11-01 00:30:00 65.166672 139.885329 0.0 33.500757 \n",
"2018-11-01 00:45:00 65.358078 139.731901 0.0 42.203876 \n",
"2018-11-01 01:00:00 64.947536 139.577871 0.0 18.702675 \n",
"\n",
" Tsink (NDG) MW (NDG) \n",
"2018-11-01 00:00:00 147.731814 0.0 \n",
"2018-11-01 00:15:00 148.138964 0.0 \n",
"2018-11-01 00:30:00 147.585426 0.0 \n",
"2018-11-01 00:45:00 147.547612 0.0 \n",
"2018-11-01 01:00:00 148.260335 0.0 "
]
},
"execution_count": 78,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df=df.drop(['Unnamed: 7', 'Unnamed: 8', 'Unnamed: 9', 'Unnamed: 10', 'Unnamed: 11', 'Unnamed: 12'], axis=1)\n",
"df[:5]"
]
},
{
"cell_type": "code",
"execution_count": 97,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"15"
]
},
"execution_count": 97,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"waterstorage = WaterStorage(\n",
" name='MyStorage',\n",
" max_power=10,\n",
" min_power=-10,\n",
" roundtrip_eff=0.90,\n",
" energy_density = 50 * 10e-3,\n",
" volume = 500,\n",
" lifetime = 25,\n",
" temperature = 368, #K\n",
" min_storagelevel = 5,\n",
" max_storagelevel = 23\n",
" \n",
")\n",
"waterstorage.set_freq('15T')\n",
"waterstorage.set_storagelevel(15)\n",
"waterstorage.storagelevel"
]
},
{
"cell_type": "code",
"execution_count": 98,
"metadata": {},
"outputs": [],
"source": [
"def hp_mass_flow (hp_capacity, Tsink, Tref, Cp):\n",
" return hp_capacity /(Cp*(Tsink - Tref)) \n",
"\n",
"def process_mass_flow (demand, Tsink, Tref, Cp):\n",
" return demand /(Cp*(Tsink - Tref)) \n",
"\n",
"def COP_calculation(Tsink, Tsource):\n",
" return Tsink / (Tsink - Tsource)\n",
"\n",
"from numpy.polynomial import Polynomial\n",
"\n",
"def cop_curve(Tsink, Tsource):\n",
" c0 = Tsink / (Tsink - Tsource) \n",
" return Polynomial([c0])\n"
]
},
{
"cell_type": "code",
"execution_count": 118,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'name': 'Heatpump',\n",
" 'max_th_power': 20,\n",
" 'min_th_power': 5,\n",
" 'cop_curve': <function __main__.cop_curve(Tsink, Tsource)>}"
]
},
"execution_count": 118,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# heatpump = Heatpump(\"heatpump1\", 50, cop_curve, 10)\n",
"# heatpump.set_heat_output(50, Tsource=333, Tsink=413)\n",
"cop_curve(140, 13)\n",
"\n",
"heatpump = Heatpump(\n",
" name='Heatpump',\n",
" max_th_power=20,\n",
" min_th_power=5,\n",
" cop_curve=cop_curve\n",
")\n",
"\n",
"heatpump.__dict__\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 146,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"341.450974129671"
]
},
"execution_count": 146,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Tsink = 413 #K\n",
"Tsource = 333 #K\n",
"Tref = 273 #K\n",
"hp_capacity = 31 #MW\n",
"demand = 25 #MW\n",
"Cp = 4190 #J/kgK\n",
"MW_to_J_per_s = 1000_000\n",
"hp_capacity *= MW_to_J_per_s\n",
"demand *= MW_to_J_per_s\n",
"\n",
"charge_mass_flow = hp_mass_flow (hp_capacity, Tsink, Tref, Cp) - process_mass_flow (demand, Tsink, Tref, Cp)\n",
"charged_heat = (charge_mass_flow * Cp * (Tsink - Tref)) / MW_to_J_per_s\n",
"charged_heat\n",
"\n",
"efficiency = 0.9\n",
"Tstorage = 95 + 273\n",
"discharged_heat = charged_heat * efficiency #MW\n",
"discharged_heat *= MW_to_J_per_s \n",
"discharge_mass_flow = discharged_heat /(Cp*(Tstorage - Tref))\n",
"discharge_mass_flow\n",
"process_mass_flow\n",
"\n",
"def Tsource_calculation(Tstorage, discharge_mass_flow, Tsource, process_mass_flow):\n",
" return (Tstorage * discharge_mass_flow + Tsource * process_mass_flow)/ (discharge_mass_flow + process_mass_flow)\n",
" \n",
"\n",
"Tsource_calculation(Tstorage, discharge_mass_flow, Tsource, process_mass_flow (demand, Tsink, Tref, Cp))\n"
]
},
{
"cell_type": "code",
"execution_count": 170,
"metadata": {},
"outputs": [],
"source": [
"def test_heatpump_and_waterstorage_system(Tsink, Tsource, process_demand_MW, e_price, waterstorage_level):\n",
" \"\"\"\n",
" 1. Follow a certain logic based on given price:\n",
" - If price is low --> Heatpump at full power, and charge the heatbuffer\n",
" - If price is high --> Discharge the heat buffer, and increase Tsource, which will increase COP\n",
" 2. Above logic should adhere to a couple of constraints:\n",
" - Storage levels\n",
" - Capacity of the heat pump \n",
" - Process demand\n",
" - ....\n",
" 3. This function should contain: \n",
" - Heat pump \n",
" - Water storage\n",
" - Interactions / logic between them\n",
" 4. Output of the function:\n",
" - Power of the heatpump \n",
" - \"New\" water storage level\n",
" \"\"\"\n",
" waterstorage.storage_level = waterstorage_level\n",
" \n",
" if e_price < 50:\n",
" hp_load = heatpump.max_th_power #bunu yoxla heat pump-a birbasa set load demek olmur. Ve funksiyada heatpump obyekti var ama o evvel initialize olunmayib\n",
" energy_to_storage = hp_load - process_demand_MW\n",
" waterstorage.charge(energy_to_storage)\n",
" waterstorage.charged_energy = waterstorage.MW_to_MWh(energy_to_storage)\n",
" waterstorage_level = waterstorage.storage_level\n",
" new_cl = waterstorage.storage_level + waterstorage.charged_energy\n",
" if e_price > 100:\n",
" Tstorage = 320\n",
" energy_from_storage = discharged_heat\n",
" waterstorage_level = waterstorage.storage_level\n",
" waterstorage.discharged_energy = waterstorage.MW_to_MWh(energy_from_storage)\n",
" new_cl = waterstorage.storage_level - waterstorage.discharged_energy\n",
" def Tsource_calculation(Tstorage, discharge_mass_flow, Tsource, process_mass_flow):\n",
" return (\n",
" (Tstorage * discharge_mass_flow + Tsource * process_mass_flow)\n",
" / (discharge_mass_flow + process_mass_flow)\n",
" )\n",
" new_Tsource = Tsource_calculation(Tstorage, discharge_mass_flow, Tsource, process_mass_flow (demand, Tsink, Tref, Cp))\n",
" new_COP = COP_calculation (Tsink, new_Tsource)\n",
" hp_load = heatpump.set_heat_output(process_demand_MW, Tsink, Tsource) #bu da hemcinin set load assetin funksiyasidir, \n",
" #heatpump da overwrite edilib. men evezinde yazdim ki set_heat_output\n",
" #sen gor hansi funksiya sene lazimdir.\n",
"\n",
" return hp_load"
]
},
{
"cell_type": "code",
"execution_count": 176,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"-4.25531914893617"
]
},
"execution_count": 176,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"eload = test_heatpump_and_waterstorage_system(\n",
" Tsink = 150+273, \n",
" Tsource = 60+273, \n",
" process_demand_MW = 25, \n",
" e_price = 130, \n",
" waterstorage_level = 23\n",
")\n",
"\n",
"eload[0]"
]
},
{
"cell_type": "code",
"execution_count": 177,
"metadata": {},
"outputs": [],
"source": [
"for i in df.index:\n",
" df.loc[i, 'e_load'] = test_heatpump_and_waterstorage_system(df.loc[i, 'Tsink (VDG)']+273, df.loc[i, 'Tsource (VDG)']+273, df.loc[i, 'MW (VDG)'], 130, 23)[0]"
]
},
{
"cell_type": "code",
"execution_count": 178,
"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>Tsource (VDG)</th>\n",
" <th>Tsink (VDG)</th>\n",
" <th>MW (VDG)</th>\n",
" <th>Tsource (NDG)</th>\n",
" <th>Tsink (NDG)</th>\n",
" <th>MW (NDG)</th>\n",
" <th>hp_load</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2018-11-01 00:00:00</th>\n",
" <td>64.964783</td>\n",
" <td>142.003109</td>\n",
" <td>0.000000</td>\n",
" <td>19.897433</td>\n",
" <td>147.731814</td>\n",
" <td>0.000000</td>\n",
" <td>-0.928166</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 00:15:00</th>\n",
" <td>54.578777</td>\n",
" <td>138.960493</td>\n",
" <td>0.000000</td>\n",
" <td>17.950905</td>\n",
" <td>148.138964</td>\n",
" <td>0.000000</td>\n",
" <td>-1.024148</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 00:30:00</th>\n",
" <td>65.166672</td>\n",
" <td>139.885329</td>\n",
" <td>0.000000</td>\n",
" <td>33.500757</td>\n",
" <td>147.585426</td>\n",
" <td>0.000000</td>\n",
" <td>-0.904835</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 00:45:00</th>\n",
" <td>65.358078</td>\n",
" <td>139.731901</td>\n",
" <td>0.000000</td>\n",
" <td>42.203876</td>\n",
" <td>147.547612</td>\n",
" <td>0.000000</td>\n",
" <td>-0.900994</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 01:00:00</th>\n",
" <td>64.947536</td>\n",
" <td>139.577871</td>\n",
" <td>0.000000</td>\n",
" <td>18.702675</td>\n",
" <td>148.260335</td>\n",
" <td>0.000000</td>\n",
" <td>-0.904439</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 15:30:00</th>\n",
" <td>65.016212</td>\n",
" <td>157.229508</td>\n",
" <td>20.716926</td>\n",
" <td>64.996845</td>\n",
" <td>167.135901</td>\n",
" <td>6.798455</td>\n",
" <td>-4.286702</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 15:45:00</th>\n",
" <td>64.977669</td>\n",
" <td>157.649509</td>\n",
" <td>20.631462</td>\n",
" <td>64.929398</td>\n",
" <td>166.147289</td>\n",
" <td>6.785675</td>\n",
" <td>-4.303817</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 16:00:00</th>\n",
" <td>64.946152</td>\n",
" <td>157.807772</td>\n",
" <td>20.608221</td>\n",
" <td>64.789982</td>\n",
" <td>164.705055</td>\n",
" <td>6.795423</td>\n",
" <td>-4.311047</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 16:15:00</th>\n",
" <td>64.940338</td>\n",
" <td>157.965580</td>\n",
" <td>20.589894</td>\n",
" <td>64.489296</td>\n",
" <td>163.434915</td>\n",
" <td>6.804813</td>\n",
" <td>-4.317061</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 16:30:00</th>\n",
" <td>64.940338</td>\n",
" <td>158.070484</td>\n",
" <td>20.799079</td>\n",
" <td>64.245148</td>\n",
" <td>163.312629</td>\n",
" <td>6.876395</td>\n",
" <td>-4.320878</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>67 rows × 7 columns</p>\n",
"</div>"
],
"text/plain": [
" Tsource (VDG) Tsink (VDG) MW (VDG) Tsource (NDG) \\\n",
"2018-11-01 00:00:00 64.964783 142.003109 0.000000 19.897433 \n",
"2018-11-01 00:15:00 54.578777 138.960493 0.000000 17.950905 \n",
"2018-11-01 00:30:00 65.166672 139.885329 0.000000 33.500757 \n",
"2018-11-01 00:45:00 65.358078 139.731901 0.000000 42.203876 \n",
"2018-11-01 01:00:00 64.947536 139.577871 0.000000 18.702675 \n",
"... ... ... ... ... \n",
"2018-11-01 15:30:00 65.016212 157.229508 20.716926 64.996845 \n",
"2018-11-01 15:45:00 64.977669 157.649509 20.631462 64.929398 \n",
"2018-11-01 16:00:00 64.946152 157.807772 20.608221 64.789982 \n",
"2018-11-01 16:15:00 64.940338 157.965580 20.589894 64.489296 \n",
"2018-11-01 16:30:00 64.940338 158.070484 20.799079 64.245148 \n",
"\n",
" Tsink (NDG) MW (NDG) hp_load \n",
"2018-11-01 00:00:00 147.731814 0.000000 -0.928166 \n",
"2018-11-01 00:15:00 148.138964 0.000000 -1.024148 \n",
"2018-11-01 00:30:00 147.585426 0.000000 -0.904835 \n",
"2018-11-01 00:45:00 147.547612 0.000000 -0.900994 \n",
"2018-11-01 01:00:00 148.260335 0.000000 -0.904439 \n",
"... ... ... ... \n",
"2018-11-01 15:30:00 167.135901 6.798455 -4.286702 \n",
"2018-11-01 15:45:00 166.147289 6.785675 -4.303817 \n",
"2018-11-01 16:00:00 164.705055 6.795423 -4.311047 \n",
"2018-11-01 16:15:00 163.434915 6.804813 -4.317061 \n",
"2018-11-01 16:30:00 163.312629 6.876395 -4.320878 \n",
"\n",
"[67 rows x 7 columns]"
]
},
"execution_count": 178,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"interpreter": {
"hash": "dd1accba5c44bbc1a722925963d63420d7a225a16ee8ad40deae87a5c5fb7f29"
},
"kernelspec": {
"display_name": "Python 3.9.12 ('myenv': 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.9.12"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}