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/Simulations/.ipynb_checkpoints/Test5-simulation-checkpoint...

1598 lines
60 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": 2,
"metadata": {},
"outputs": [],
"source": [
"from notepad import WaterStorage, Heatpump\n",
"# from pyrecoy.forecasts import Mipf\n",
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"# import cufflinks\n",
"# cufflinks.go_offline()\n",
"from numpy.polynomial import Polynomial\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 5,
"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>ForeNeg</th>\n",
" <th>ForePos</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2018-11-01 00:00:00</th>\n",
" <td>91</td>\n",
" <td>34</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 00:15:00</th>\n",
" <td>39</td>\n",
" <td>31</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 00:30:00</th>\n",
" <td>52</td>\n",
" <td>29</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 00:45:00</th>\n",
" <td>108</td>\n",
" <td>42</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 01:00:00</th>\n",
" <td>49</td>\n",
" <td>36</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" ForeNeg ForePos\n",
"2018-11-01 00:00:00 91 34\n",
"2018-11-01 00:15:00 39 31\n",
"2018-11-01 00:30:00 52 29\n",
"2018-11-01 00:45:00 108 42\n",
"2018-11-01 01:00:00 49 36"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rng = pd.date_range('2018-11-01 00:00:00', end='2018-11-01 12:00:00', freq='15T' )\n",
"\n",
"price_data = pd.DataFrame(np.random.randint(30, 110, size=(len(rng))), \n",
" columns=['ForeNeg'], \n",
" index=rng)\n",
"\n",
"price_data['ForePos'] = np.random.randint(20, 50, size=(len(rng)))\n",
"\n",
"price_data.head()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"# mipf = Mipf(\n",
"# start='2018-11-01', \n",
"# end='2018-11-02', \n",
"# tidy=True, \n",
"# include_nextQ=False,\n",
"# folder_path=r\"C:\\Users\\Shahla Huseynova\\Recoy\\Recoy - Documents\\03 - Libraries\\12 - Data Management\\Forecast Data\"\n",
"# ).data\n",
"# # mipf.columns\n",
"# price_data = mipf[['DAM', 'POS', 'NEG', 'ForeNeg', 'ForePos']]\n",
"# price_data = price_data.resample('15T').mean()\n",
"# price_data"
]
},
{
"cell_type": "code",
"execution_count": 7,
"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": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data = pd.read_excel('Demand_Data_Smurfit_Preprocessed.xlsx', sheet_name='nov2018', index_col=0)\n",
"start, end = '2018-11-01 00:00:00', '2018-11-01 12:00:00'\n",
"df = data[start:end]\n",
"df = df.resample('15T', origin=start).mean()\n",
"df=df.drop(['Unnamed: 7', 'Unnamed: 8', 'Unnamed: 9', 'Unnamed: 10', 'Unnamed: 11', 'Unnamed: 12'], axis=1)\n",
"\n",
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"# df[['Tsource (VDG)', 'Tsink (VDG)']].iplot()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"15"
]
},
"execution_count": 9,
"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",
" capacity_per_volume = 50 * 1e-3,\n",
" volume = 1000,\n",
" lifetime = 25,\n",
" temperature = 368, #K\n",
" min_storagelevel = 5,\n",
" # max_storagelevel = 50\n",
" \n",
")\n",
"waterstorage.set_freq('15T')\n",
"waterstorage.set_storagelevel(15)\n",
"waterstorage.storagelevel"
]
},
{
"cell_type": "code",
"execution_count": 110,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"process demand 25\n"
]
}
],
"source": [
"Tsink = 140 #Celcius\n",
"Tsource = 60\n",
"Tref = 0\n",
"hp_capacity = 31 #MW\n",
"process_demand_MW = 25 #MW\n",
"Cp = 4190 #J/kgK\n",
"MWtoJs = 1000_000\n",
"# hp_capacity *= MW_to_J_per_s\n",
"# process_demand_MW *= MW_to_J_per_s\n",
"efficiency = 0.9\n",
"Tstorage = 95\n",
"\n",
"print('process demand', process_demand_MW)\n",
"# hp_capacity vs hp_load?"
]
},
{
"cell_type": "code",
"execution_count": 111,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"50.0"
]
},
"execution_count": 111,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"waterstorage.max_storage_capacity"
]
},
{
"cell_type": "code",
"execution_count": 112,
"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 (process_demand_MW, Tsink, Tref, Cp):\n",
" return process_demand_MW /(Cp*(Tsink - Tref)) \n",
"\n",
"def cop_curve(Tsink, Tsource):\n",
" c0 = Tsink / (Tsink - Tsource) \n",
" return Polynomial([c0])\n",
"\n",
"charge_mass_flow = hp_mass_flow (hp_capacity, Tsink, Tref, Cp) - process_mass_flow (process_demand_MW, Tsink, Tref, Cp)\n",
"\n",
"\n",
"def energy_to_storage(hp_capacity, process_demand_MW):\n",
" return hp_capacity - process_demand_MW\n",
"\n",
"\n",
"discharged_heat = energy_to_storage(hp_capacity, process_demand_MW) #MW\n",
"\n",
"# def charged_heat (charge_mass_flow, Cp, Tsink, Tref):\n",
"# return (charge_mass_flow * Cp * (Tsink - Tref)) / MW_to_J_per_s\n",
"\n",
"# discharged_heat = charged_heat(charge_mass_flow, Cp, Tsink, Tref) #MW\n",
"\n",
"def discharge_mass_flow (discharged_heat, Cp, Tstorage, Tref):\n",
" return discharged_heat*MWtoJs/(Cp*(Tstorage - Tref))\n",
"\n",
"def Tsource_calculation(Tstorage, discharge_mass_flow, Tsource, process_mass_flow):\n",
" return ((Tstorage * discharge_mass_flow + Tsource * process_mass_flow)\n",
" / (discharge_mass_flow + process_mass_flow))\n",
"\n",
"\n",
"# charged_heat can be also defined as hp_capacity-process_demand_MW"
]
},
{
"cell_type": "code",
"execution_count": 113,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"11.414895999999999\n",
"19.459420388680527\n"
]
}
],
"source": [
"discharged_heat = energy_to_storage(hp_capacity,19.585104)\n",
"\n",
"print(discharged_heat)\n",
"\n",
"discharge_mass = discharge_mass_flow(discharged_heat, Cp, 140+273, Tref+273)\n",
"\n",
"print(discharge_mass)"
]
},
{
"cell_type": "code",
"execution_count": 114,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'name': 'Heatpump',\n",
" 'max_th_power': 40,\n",
" 'min_th_power': 5,\n",
" 'cop_curve': <function __main__.cop_curve(Tsink, Tsource)>}"
]
},
"execution_count": 114,
"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, 60)\n",
"\n",
"heatpump = Heatpump(\n",
" name='Heatpump',\n",
" max_th_power=40,\n",
" min_th_power=5,\n",
" cop_curve=cop_curve\n",
")\n",
"\n",
"heatpump.__dict__\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 115,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"5.1625"
]
},
"execution_count": 115,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"heatpump.get_cop(50, Tsource=333, Tsink=413)\n"
]
},
{
"cell_type": "code",
"execution_count": 116,
"metadata": {},
"outputs": [],
"source": [
"# def test_heatpump_and_waterstorage_system(Tsink, Tsource, process_demand_MW, e_price):\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 (MWe)\n",
"# - \"New\" water storage level\n",
"# - (optional) Thermal output of the heatpump\n",
"# - (optional) In/outflow from the storage\n",
"# \"\"\"\n",
" \n",
"# if e_price < 50:\n",
"# hp_load = heatpump.max_th_power\n",
"# energy_to_storage = hp_load - process_demand_MW\n",
"# waterstorage.charge(energy_to_storage)\n",
"# new_cl = waterstorage.storagelevel\n",
"# if e_price > 100:\n",
"# energy_from_storage = discharged_heat\n",
"# waterstorage.discharge(energy_from_storage)\n",
"# new_cl = waterstorage.storagelevel\n",
" \n",
"# def Tsource_calculation(Tstorage, discharge_mass_flow, Tsource, process_mass_flow):\n",
"# return ((Tstorage * discharge_mass_flow(discharged_heat, Cp, Tstorage, Tref) + Tsource * process_mass_flow(process_demand_MW, Tsink, Tref, Cp))\n",
"# / (discharge_mass_flow(discharged_heat, Cp, Tstorage, Tref) + process_mass_flow(process_demand_MW, Tsink, Tref, Cp)))\n",
"# new_COP = cop_curve (Tsink, Tsource_calculation(Tstorage, discharge_mass_flow, Tsource, process_mass_flow))\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, new_cl"
]
},
{
"cell_type": "code",
"execution_count": 117,
"metadata": {},
"outputs": [],
"source": [
"# waterstorage.get_soc (30, 50)"
]
},
{
"cell_type": "code",
"execution_count": 118,
"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>ForeNeg</th>\n",
" <th>ForePos</th>\n",
" <th>hp_mass</th>\n",
" <th>process_mass</th>\n",
" <th>COP</th>\n",
" <th>charge_mass</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>91</td>\n",
" <td>34</td>\n",
" <td>0.000052</td>\n",
" <td>0.000000</td>\n",
" <td>(5.386969459992516)</td>\n",
" <td>0.000052</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>39</td>\n",
" <td>31</td>\n",
" <td>0.000053</td>\n",
" <td>0.000000</td>\n",
" <td>(4.882106135030027)</td>\n",
" <td>0.000053</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>52</td>\n",
" <td>29</td>\n",
" <td>0.000053</td>\n",
" <td>0.000000</td>\n",
" <td>(5.5258665771869335)</td>\n",
" <td>0.000053</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>108</td>\n",
" <td>42</td>\n",
" <td>0.000053</td>\n",
" <td>0.000000</td>\n",
" <td>(5.549424302045392)</td>\n",
" <td>0.000053</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>49</td>\n",
" <td>36</td>\n",
" <td>0.000053</td>\n",
" <td>0.000000</td>\n",
" <td>(5.528286493353138)</td>\n",
" <td>0.000053</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 01:15:00</th>\n",
" <td>65.073433</td>\n",
" <td>139.423357</td>\n",
" <td>0.000000</td>\n",
" <td>19.903652</td>\n",
" <td>149.186865</td>\n",
" <td>0.000000</td>\n",
" <td>75</td>\n",
" <td>27</td>\n",
" <td>0.000053</td>\n",
" <td>0.000000</td>\n",
" <td>(5.547058190973266)</td>\n",
" <td>0.000053</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 01:30:00</th>\n",
" <td>47.711559</td>\n",
" <td>140.328730</td>\n",
" <td>0.000000</td>\n",
" <td>19.574467</td>\n",
" <td>147.800016</td>\n",
" <td>0.000000</td>\n",
" <td>100</td>\n",
" <td>22</td>\n",
" <td>0.000053</td>\n",
" <td>0.000000</td>\n",
" <td>(4.462765657815752)</td>\n",
" <td>0.000053</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 01:45:00</th>\n",
" <td>29.525829</td>\n",
" <td>140.298902</td>\n",
" <td>0.000000</td>\n",
" <td>17.065464</td>\n",
" <td>147.906886</td>\n",
" <td>0.000000</td>\n",
" <td>54</td>\n",
" <td>45</td>\n",
" <td>0.000053</td>\n",
" <td>0.000000</td>\n",
" <td>(3.731041234226957)</td>\n",
" <td>0.000053</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 02:00:00</th>\n",
" <td>65.715569</td>\n",
" <td>139.991650</td>\n",
" <td>10.139587</td>\n",
" <td>49.339708</td>\n",
" <td>149.603741</td>\n",
" <td>3.333301</td>\n",
" <td>100</td>\n",
" <td>42</td>\n",
" <td>0.000053</td>\n",
" <td>0.000017</td>\n",
" <td>(5.560223997670469)</td>\n",
" <td>0.000036</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 02:15:00</th>\n",
" <td>65.929909</td>\n",
" <td>148.342325</td>\n",
" <td>19.585104</td>\n",
" <td>61.721718</td>\n",
" <td>155.887905</td>\n",
" <td>6.455359</td>\n",
" <td>85</td>\n",
" <td>36</td>\n",
" <td>0.000050</td>\n",
" <td>0.000032</td>\n",
" <td>(5.112607341877656)</td>\n",
" <td>0.000018</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.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",
"2018-11-01 01:15:00 65.073433 139.423357 0.000000 19.903652 \n",
"2018-11-01 01:30:00 47.711559 140.328730 0.000000 19.574467 \n",
"2018-11-01 01:45:00 29.525829 140.298902 0.000000 17.065464 \n",
"2018-11-01 02:00:00 65.715569 139.991650 10.139587 49.339708 \n",
"2018-11-01 02:15:00 65.929909 148.342325 19.585104 61.721718 \n",
"\n",
" Tsink (NDG) MW (NDG) ForeNeg ForePos hp_mass \\\n",
"2018-11-01 00:00:00 147.731814 0.000000 91 34 0.000052 \n",
"2018-11-01 00:15:00 148.138964 0.000000 39 31 0.000053 \n",
"2018-11-01 00:30:00 147.585426 0.000000 52 29 0.000053 \n",
"2018-11-01 00:45:00 147.547612 0.000000 108 42 0.000053 \n",
"2018-11-01 01:00:00 148.260335 0.000000 49 36 0.000053 \n",
"2018-11-01 01:15:00 149.186865 0.000000 75 27 0.000053 \n",
"2018-11-01 01:30:00 147.800016 0.000000 100 22 0.000053 \n",
"2018-11-01 01:45:00 147.906886 0.000000 54 45 0.000053 \n",
"2018-11-01 02:00:00 149.603741 3.333301 100 42 0.000053 \n",
"2018-11-01 02:15:00 155.887905 6.455359 85 36 0.000050 \n",
"\n",
" process_mass COP charge_mass \n",
"2018-11-01 00:00:00 0.000000 (5.386969459992516) 0.000052 \n",
"2018-11-01 00:15:00 0.000000 (4.882106135030027) 0.000053 \n",
"2018-11-01 00:30:00 0.000000 (5.5258665771869335) 0.000053 \n",
"2018-11-01 00:45:00 0.000000 (5.549424302045392) 0.000053 \n",
"2018-11-01 01:00:00 0.000000 (5.528286493353138) 0.000053 \n",
"2018-11-01 01:15:00 0.000000 (5.547058190973266) 0.000053 \n",
"2018-11-01 01:30:00 0.000000 (4.462765657815752) 0.000053 \n",
"2018-11-01 01:45:00 0.000000 (3.731041234226957) 0.000053 \n",
"2018-11-01 02:00:00 0.000017 (5.560223997670469) 0.000036 \n",
"2018-11-01 02:15:00 0.000032 (5.112607341877656) 0.000018 "
]
},
"execution_count": 118,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"for col in price_data.columns:\n",
" df[col] = price_data[col]\n",
"df.head(10)\n",
"# iki dataframeni birlesdirdik burda"
]
},
{
"cell_type": "code",
"execution_count": 119,
"metadata": {},
"outputs": [],
"source": [
"# for i in df.index:\n",
"# df.loc[i, 'hp_mass'] = hp_mass_flow(hp_capacity, df.loc[i, 'Tsink (VDG)'], Tref, Cp)\n",
"# df.loc[i, 'process_mass'] = process_mass_flow(df.loc[i, 'MW (VDG)'], df.loc[i, 'Tsink (VDG)'],Tref, Cp)\n",
"# df.loc[i, 'COP'] = cop_curve(df.loc[i, 'Tsink (VDG)']+273, df.loc[i, 'Tsource (VDG)']+273)\n",
"# df.loc[i, 'charge_mass'] = df.loc[i, 'hp_mass'] - df.loc[i, 'process_mass']\n",
"# # df.loc[i, 'charged_heat'] = charged_heat(df.loc[i, 'charge_mass'], Cp, df.loc[i, 'Tsink (VDG)']+273, Tref + 273)\n",
"# # df.loc[i, 'discharged_heat'] = charged_heat(df.loc[i, 'charge_mass'], Cp, df.loc[i, 'Tsink (VDG)']+273, Tref + 273)\n",
"# # df.loc[i, 'discharge_mass'] = discharge_mass_flow(df.loc[i, 'discharged_heat'], Cp, Tstorage+273, Tref+273)\n",
"# # df.loc[i, 'Tsource_new'] = Tsource_calculation(Tstorage + 273, df.loc[i, 'discharge_mass'], df.loc[i, 'Tsource (VDG)']+273, df.loc[i, 'process_mass'])\n",
"# # df.loc[i, 'new_COP'] = cop_curve(df.loc[i, 'Tsink (VDG)']+273, df.loc[i, 'Tsource_new'])\n",
" \n",
"# df.head(10)\n",
"# Tsource_new should be in the nested function but now it is calculated separately, need to be checked again\n",
"# discharge_mass were checked manually,there is very slight change in the last decimals that's why seems constant here, but it calculates correctly.\n",
"\n",
"# process mass results are wrong"
]
},
{
"cell_type": "code",
"execution_count": 125,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"52.94831003899137\n",
"17.232571785757365\n",
"15.690906523897725\n",
"15.833641124244465\n",
"15.766858500063137\n"
]
}
],
"source": [
"# df.index = df.index.tz_localize('Europe/Amsterdam')\n",
"for i in df.index:\n",
" # if df.loc[i, 'ForePos'] < 50:\n",
" # hp_load = heatpump.max_th_power\n",
" # energy_to_storage = hp_load - df.loc[i, 'MW (VDG)']\n",
" # waterstorage.charge(energy_to_storage)\n",
" # new_cl = waterstorage.storagelevel\n",
" # print(new_cl)\n",
" if price_data.loc[i,'ForeNeg'] > 100:\n",
" # discharged_heat = energy_to_storage(hp_capacity, df.loc[i, 'MW (VDG)'])\n",
" energy_from_storage = energy_to_storage(hp_capacity, df.loc[i, 'MW (VDG)'])\n",
" waterstorage.discharge(energy_from_storage)\n",
" new_cl = waterstorage.storagelevel\n",
" discharge_mass = discharge_mass_flow(energy_from_storage, Cp, df.loc[i, 'Tsink (VDG)']+273, Tref + 273)\n",
" print(discharge_mass)\n",
" Tsource_new = Tsource_calculation(Tstorage, discharge_mass, Tsource, process_mass_flow(df.loc[i, 'MW (VDG)'], df.loc[i, 'Tsink (VDG)'], Tref, Cp))\n",
" new_COP = cop_curve (df.loc[i, 'Tsink (VDG)']+273, Tsource_new+273)\n",
" # # print(new_COP) "
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"ename": "TypeError",
"evalue": "'numpy.float64' object is not callable",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32mC:\\Users\\SHAHLA~1\\AppData\\Local\\Temp/ipykernel_20628/3532083246.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mindex\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mloc\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'charged_heat'\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0menergy_to_storage\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mhp_capacity\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mloc\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'MW (VDG)'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 3\u001b[0m \u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mloc\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'discharged_heat'\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mloc\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'charged_heat'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mloc\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'discharge_mass'\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mdischarge_mass_flow\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mloc\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'discharged_heat'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mCp\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mTstorage\u001b[0m\u001b[1;33m+\u001b[0m\u001b[1;36m273\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mTref\u001b[0m\u001b[1;33m+\u001b[0m\u001b[1;36m273\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mloc\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'Tsource_new'\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mTsource_calculation\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mTstorage\u001b[0m \u001b[1;33m+\u001b[0m \u001b[1;36m273\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mloc\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'discharge_mass'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mloc\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'Tsource (VDG)'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m+\u001b[0m\u001b[1;36m273\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mloc\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'process_mass'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mTypeError\u001b[0m: 'numpy.float64' object is not callable"
]
}
],
"source": [
"for i in df.index:\n",
" df.loc[i, 'charged_heat'] = energy_to_storage(hp_capacity, df.loc[i, 'MW (VDG)'])\n",
" df.loc[i, 'discharged_heat'] = df.loc[i, 'charged_heat']\n",
" df.loc[i, 'discharge_mass'] = discharge_mass_flow(df.loc[i, 'discharged_heat'], Cp, Tstorage+273, Tref+273)\n",
" df.loc[i, 'Tsource_new'] = Tsource_calculation(Tstorage + 273, df.loc[i, 'discharge_mass'], df.loc[i, 'Tsource (VDG)']+273, df.loc[i, 'process_mass'])\n",
" df.loc[i, 'new_COP'] = cop_curve(df.loc[i, 'Tsink (VDG)']+273, df.loc[i, 'Tsource_new'])\n",
" \n",
"df.head(10)"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {},
"outputs": [],
"source": [
"# for i in df.index:\n",
"# # df.loc[i, 'MWe'] = test_heatpump_and_waterstorage_system(df.loc[i, 'Tsink (VDG)']+273, df.loc[i, 'Tsource (VDG)']+273, df.loc[i, 'MW (VDG)'], 130)[0][0]\n",
"# df.loc[i, 'new_cl'] = test_heatpump_and_waterstorage_system(df.loc[i, 'Tsink (VDG)']+273, df.loc[i, 'Tsource (VDG)']+273, df.loc[i, 'MW (VDG)'], 30)[1]\n"
]
},
{
"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>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>ForeNeg</th>\n",
" <th>ForePos</th>\n",
" <th>hp_mass</th>\n",
" <th>process_mass</th>\n",
" <th>COP</th>\n",
" <th>charge_mass</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>109</td>\n",
" <td>43</td>\n",
" <td>52.101451</td>\n",
" <td>0.000000</td>\n",
" <td>(5.386969459992516)</td>\n",
" <td>52.101451</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>34</td>\n",
" <td>46</td>\n",
" <td>53.242241</td>\n",
" <td>0.000000</td>\n",
" <td>(4.882106135030027)</td>\n",
" <td>53.242241</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>45</td>\n",
" <td>48</td>\n",
" <td>52.890236</td>\n",
" <td>0.000000</td>\n",
" <td>(5.5258665771869335)</td>\n",
" <td>52.890236</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>94</td>\n",
" <td>38</td>\n",
" <td>52.948310</td>\n",
" <td>0.000000</td>\n",
" <td>(5.549424302045392)</td>\n",
" <td>52.948310</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>102</td>\n",
" <td>24</td>\n",
" <td>53.006741</td>\n",
" <td>0.000000</td>\n",
" <td>(5.528286493353138)</td>\n",
" <td>53.006741</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 01:15:00</th>\n",
" <td>65.073433</td>\n",
" <td>139.423357</td>\n",
" <td>0.000000</td>\n",
" <td>19.903652</td>\n",
" <td>149.186865</td>\n",
" <td>0.000000</td>\n",
" <td>69</td>\n",
" <td>40</td>\n",
" <td>53.065485</td>\n",
" <td>0.000000</td>\n",
" <td>(5.547058190973266)</td>\n",
" <td>53.065485</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 01:30:00</th>\n",
" <td>47.711559</td>\n",
" <td>140.328730</td>\n",
" <td>0.000000</td>\n",
" <td>19.574467</td>\n",
" <td>147.800016</td>\n",
" <td>0.000000</td>\n",
" <td>78</td>\n",
" <td>46</td>\n",
" <td>52.723117</td>\n",
" <td>0.000000</td>\n",
" <td>(4.462765657815752)</td>\n",
" <td>52.723117</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 01:45:00</th>\n",
" <td>29.525829</td>\n",
" <td>140.298902</td>\n",
" <td>0.000000</td>\n",
" <td>17.065464</td>\n",
" <td>147.906886</td>\n",
" <td>0.000000</td>\n",
" <td>94</td>\n",
" <td>23</td>\n",
" <td>52.734326</td>\n",
" <td>0.000000</td>\n",
" <td>(3.731041234226957)</td>\n",
" <td>52.734326</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 02:00:00</th>\n",
" <td>65.715569</td>\n",
" <td>139.991650</td>\n",
" <td>10.139587</td>\n",
" <td>49.339708</td>\n",
" <td>149.603741</td>\n",
" <td>3.333301</td>\n",
" <td>97</td>\n",
" <td>24</td>\n",
" <td>52.850067</td>\n",
" <td>0.000017</td>\n",
" <td>(5.560223997670469)</td>\n",
" <td>52.850049</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2018-11-01 02:15:00</th>\n",
" <td>65.929909</td>\n",
" <td>148.342325</td>\n",
" <td>19.585104</td>\n",
" <td>61.721718</td>\n",
" <td>155.887905</td>\n",
" <td>6.455359</td>\n",
" <td>105</td>\n",
" <td>44</td>\n",
" <td>49.874963</td>\n",
" <td>0.000032</td>\n",
" <td>(5.112607341877656)</td>\n",
" <td>49.874932</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.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",
"2018-11-01 01:15:00 65.073433 139.423357 0.000000 19.903652 \n",
"2018-11-01 01:30:00 47.711559 140.328730 0.000000 19.574467 \n",
"2018-11-01 01:45:00 29.525829 140.298902 0.000000 17.065464 \n",
"2018-11-01 02:00:00 65.715569 139.991650 10.139587 49.339708 \n",
"2018-11-01 02:15:00 65.929909 148.342325 19.585104 61.721718 \n",
"\n",
" Tsink (NDG) MW (NDG) ForeNeg ForePos hp_mass \\\n",
"2018-11-01 00:00:00 147.731814 0.000000 109 43 52.101451 \n",
"2018-11-01 00:15:00 148.138964 0.000000 34 46 53.242241 \n",
"2018-11-01 00:30:00 147.585426 0.000000 45 48 52.890236 \n",
"2018-11-01 00:45:00 147.547612 0.000000 94 38 52.948310 \n",
"2018-11-01 01:00:00 148.260335 0.000000 102 24 53.006741 \n",
"2018-11-01 01:15:00 149.186865 0.000000 69 40 53.065485 \n",
"2018-11-01 01:30:00 147.800016 0.000000 78 46 52.723117 \n",
"2018-11-01 01:45:00 147.906886 0.000000 94 23 52.734326 \n",
"2018-11-01 02:00:00 149.603741 3.333301 97 24 52.850067 \n",
"2018-11-01 02:15:00 155.887905 6.455359 105 44 49.874963 \n",
"\n",
" process_mass COP charge_mass \n",
"2018-11-01 00:00:00 0.000000 (5.386969459992516) 52.101451 \n",
"2018-11-01 00:15:00 0.000000 (4.882106135030027) 53.242241 \n",
"2018-11-01 00:30:00 0.000000 (5.5258665771869335) 52.890236 \n",
"2018-11-01 00:45:00 0.000000 (5.549424302045392) 52.948310 \n",
"2018-11-01 01:00:00 0.000000 (5.528286493353138) 53.006741 \n",
"2018-11-01 01:15:00 0.000000 (5.547058190973266) 53.065485 \n",
"2018-11-01 01:30:00 0.000000 (4.462765657815752) 52.723117 \n",
"2018-11-01 01:45:00 0.000000 (3.731041234226957) 52.734326 \n",
"2018-11-01 02:00:00 0.000017 (5.560223997670469) 52.850049 \n",
"2018-11-01 02:15:00 0.000032 (5.112607341877656) 49.874932 "
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[:10]"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
"# data['Total demand'] = data['MW (VDG)'] + data['MW (NDG)']\n",
"# data = data[start:end]\n",
"# fig_demands_nov2018 = data['Total demand'].resample('1H').mean().iplot(\n",
"# title='Smurfit Kappa: Heat demand in MW', \n",
"# yTitle='MW', \n",
"# asFigure=True,\n",
"# dimensions=(800, 400)\n",
"# )\n",
"# fig_demands_nov2018"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [],
"source": [
"# import plotly.express as px\n",
"\n",
"# fig = px.line(df['new_cl'])\n",
"# fig.show()"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
"df.index = df.index.tz_localize('Europe/Amsterdam')"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [],
"source": [
"for col in price_data.columns:\n",
" df[col] = price_data[col]\n",
"\n",
"df['nomination_MWh'] = df['DAM'] * df['MW (VDG)']\n",
"df['heatpump_cons_MWh'] = 9\n",
"df['imbalance_MWh'] = df['nomination_MWh'] - df['heatpump_cons_MWh']\n",
"df['day-ahead costs'] = df['nomination_MWh'] * df['DAM'] \n",
"\n",
"is_pos = df['imbalance_MWh'] > 0\n",
"df.loc[is_pos, 'imbalance costs'] = -df.loc[is_pos, 'imbalance_MWh'] * df['POS'] \n",
"\n",
"is_neg = df['imbalance_MWh'] < 0\n",
"df.loc[is_neg, 'imbalance costs'] = -df.loc[is_neg, 'imbalance_MWh'] * df['NEG'] \n",
"\n",
"df['total cost'] = df['day-ahead costs'] + df['imbalance costs']"
]
},
{
"cell_type": "code",
"execution_count": 37,
"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_mass</th>\n",
" <th>process_mass</th>\n",
" <th>COP</th>\n",
" <th>charge_mass</th>\n",
" <th>...</th>\n",
" <th>ForeNeg</th>\n",
" <th>ForePos</th>\n",
" <th>charged_heat</th>\n",
" <th>discharged_heat</th>\n",
" <th>nomination_MWh</th>\n",
" <th>heatpump_cons_MWh</th>\n",
" <th>imbalance_MWh</th>\n",
" <th>day-ahead costs</th>\n",
" <th>imbalance costs</th>\n",
" <th>total cost</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>52.101451</td>\n",
" <td>0.000042</td>\n",
" <td>(5.386969459992516)</td>\n",
" <td>52.101409</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>30.999975</td>\n",
" <td>30.999975</td>\n",
" <td>NaN</td>\n",
" <td>9</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: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>53.242241</td>\n",
" <td>0.000043</td>\n",
" <td>(4.882106135030027)</td>\n",
" <td>53.242198</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>9</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.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>52.890236</td>\n",
" <td>0.000043</td>\n",
" <td>(5.5258665771869335)</td>\n",
" <td>52.890193</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>9</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: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>52.948310</td>\n",
" <td>0.000043</td>\n",
" <td>(5.549424302045392)</td>\n",
" <td>52.948267</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>9</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>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>53.006741</td>\n",
" <td>0.000043</td>\n",
" <td>(5.528286493353138)</td>\n",
" <td>53.006698</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>9</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:15:00</th>\n",
" <td>65.073433</td>\n",
" <td>139.423357</td>\n",
" <td>0.000000</td>\n",
" <td>19.903652</td>\n",
" <td>149.186865</td>\n",
" <td>0.000000</td>\n",
" <td>53.065485</td>\n",
" <td>0.000043</td>\n",
" <td>(5.547058190973266)</td>\n",
" <td>53.065442</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>9</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>47.711559</td>\n",
" <td>140.328730</td>\n",
" <td>0.000000</td>\n",
" <td>19.574467</td>\n",
" <td>147.800016</td>\n",
" <td>0.000000</td>\n",
" <td>52.723117</td>\n",
" <td>0.000043</td>\n",
" <td>(4.462765657815752)</td>\n",
" <td>52.723074</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>9</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:45:00</th>\n",
" <td>29.525829</td>\n",
" <td>140.298902</td>\n",
" <td>0.000000</td>\n",
" <td>17.065464</td>\n",
" <td>147.906886</td>\n",
" <td>0.000000</td>\n",
" <td>52.734326</td>\n",
" <td>0.000043</td>\n",
" <td>(3.731041234226957)</td>\n",
" <td>52.734283</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>9</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 02:00:00</th>\n",
" <td>65.715569</td>\n",
" <td>139.991650</td>\n",
" <td>10.139587</td>\n",
" <td>49.339708</td>\n",
" <td>149.603741</td>\n",
" <td>3.333301</td>\n",
" <td>52.850067</td>\n",
" <td>0.000043</td>\n",
" <td>(5.560223997670469)</td>\n",
" <td>52.850024</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>9</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 02:15:00</th>\n",
" <td>65.929909</td>\n",
" <td>148.342325</td>\n",
" <td>19.585104</td>\n",
" <td>61.721718</td>\n",
" <td>155.887905</td>\n",
" <td>6.455359</td>\n",
" <td>49.874963</td>\n",
" <td>0.000040</td>\n",
" <td>(5.112607341877656)</td>\n",
" <td>49.874923</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>9</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>10 rows × 23 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",
"2018-11-01 01:15:00 65.073433 139.423357 0.000000 19.903652 \n",
"2018-11-01 01:30:00 47.711559 140.328730 0.000000 19.574467 \n",
"2018-11-01 01:45:00 29.525829 140.298902 0.000000 17.065464 \n",
"2018-11-01 02:00:00 65.715569 139.991650 10.139587 49.339708 \n",
"2018-11-01 02:15:00 65.929909 148.342325 19.585104 61.721718 \n",
"\n",
" Tsink (NDG) MW (NDG) hp_mass process_mass \\\n",
"2018-11-01 00:00:00 147.731814 0.000000 52.101451 0.000042 \n",
"2018-11-01 00:15:00 148.138964 0.000000 53.242241 0.000043 \n",
"2018-11-01 00:30:00 147.585426 0.000000 52.890236 0.000043 \n",
"2018-11-01 00:45:00 147.547612 0.000000 52.948310 0.000043 \n",
"2018-11-01 01:00:00 148.260335 0.000000 53.006741 0.000043 \n",
"2018-11-01 01:15:00 149.186865 0.000000 53.065485 0.000043 \n",
"2018-11-01 01:30:00 147.800016 0.000000 52.723117 0.000043 \n",
"2018-11-01 01:45:00 147.906886 0.000000 52.734326 0.000043 \n",
"2018-11-01 02:00:00 149.603741 3.333301 52.850067 0.000043 \n",
"2018-11-01 02:15:00 155.887905 6.455359 49.874963 0.000040 \n",
"\n",
" COP charge_mass ... ForeNeg ForePos \\\n",
"2018-11-01 00:00:00 (5.386969459992516) 52.101409 ... NaN NaN \n",
"2018-11-01 00:15:00 (4.882106135030027) 53.242198 ... NaN NaN \n",
"2018-11-01 00:30:00 (5.5258665771869335) 52.890193 ... NaN NaN \n",
"2018-11-01 00:45:00 (5.549424302045392) 52.948267 ... NaN NaN \n",
"2018-11-01 01:00:00 (5.528286493353138) 53.006698 ... NaN NaN \n",
"2018-11-01 01:15:00 (5.547058190973266) 53.065442 ... NaN NaN \n",
"2018-11-01 01:30:00 (4.462765657815752) 52.723074 ... NaN NaN \n",
"2018-11-01 01:45:00 (3.731041234226957) 52.734283 ... NaN NaN \n",
"2018-11-01 02:00:00 (5.560223997670469) 52.850024 ... NaN NaN \n",
"2018-11-01 02:15:00 (5.112607341877656) 49.874923 ... NaN NaN \n",
"\n",
" charged_heat discharged_heat nomination_MWh \\\n",
"2018-11-01 00:00:00 30.999975 30.999975 NaN \n",
"2018-11-01 00:15:00 NaN NaN NaN \n",
"2018-11-01 00:30:00 NaN NaN NaN \n",
"2018-11-01 00:45:00 NaN NaN NaN \n",
"2018-11-01 01:00:00 NaN NaN NaN \n",
"2018-11-01 01:15:00 NaN NaN NaN \n",
"2018-11-01 01:30:00 NaN NaN NaN \n",
"2018-11-01 01:45:00 NaN NaN NaN \n",
"2018-11-01 02:00:00 NaN NaN NaN \n",
"2018-11-01 02:15:00 NaN NaN NaN \n",
"\n",
" heatpump_cons_MWh imbalance_MWh day-ahead costs \\\n",
"2018-11-01 00:00:00 9 NaN NaN \n",
"2018-11-01 00:15:00 9 NaN NaN \n",
"2018-11-01 00:30:00 9 NaN NaN \n",
"2018-11-01 00:45:00 9 NaN NaN \n",
"2018-11-01 01:00:00 9 NaN NaN \n",
"2018-11-01 01:15:00 9 NaN NaN \n",
"2018-11-01 01:30:00 9 NaN NaN \n",
"2018-11-01 01:45:00 9 NaN NaN \n",
"2018-11-01 02:00:00 9 NaN NaN \n",
"2018-11-01 02:15:00 9 NaN NaN \n",
"\n",
" imbalance costs total cost \n",
"2018-11-01 00:00:00 NaN NaN \n",
"2018-11-01 00:15:00 NaN NaN \n",
"2018-11-01 00:30:00 NaN NaN \n",
"2018-11-01 00:45:00 NaN NaN \n",
"2018-11-01 01:00:00 NaN NaN \n",
"2018-11-01 01:15:00 NaN NaN \n",
"2018-11-01 01:30:00 NaN NaN \n",
"2018-11-01 01:45:00 NaN NaN \n",
"2018-11-01 02:00:00 NaN NaN \n",
"2018-11-01 02:15:00 NaN NaN \n",
"\n",
"[10 rows x 23 columns]"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[:10]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "raw",
"metadata": {},
"source": []
}
],
"metadata": {
"interpreter": {
"hash": "7f2ef37d4cd98e77829d8e11e50cd33d70bb304d4b7429ca9cbfd34f7e6ffe13"
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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"
}
},
"nbformat": 4,
"nbformat_minor": 4
}