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.
897 lines
28 KiB
Plaintext
897 lines
28 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 40,
|
|
"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": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Developments steps to take: \n",
|
|
"* Test the WaterStorage\n",
|
|
"* Create some example for WaterStorage\n",
|
|
"* Define interactions WaterStorage <> Heatpump\n",
|
|
"* Create some example for WaterStorage + Heatpump\n",
|
|
"* Develop the interactions --> Create working examples"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## WaterStorage"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Functional requirements for the WaterStorage:\n",
|
|
"* Given: \n",
|
|
" * Size / capacity\n",
|
|
" * Temperature in/out\n",
|
|
" * Max power\n",
|
|
" * Roundtripp efficiency\n",
|
|
"* It should be able to execute commands, like: \n",
|
|
" * Charge\n",
|
|
" * Discharge\n",
|
|
" * Whats the storage level? \n",
|
|
" * Assign financials \n",
|
|
" * Take into account storage losses (time dependent)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 41,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"ename": "TypeError",
|
|
"evalue": "__init__() got an unexpected keyword argument 'max_storagelevel'",
|
|
"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_3084/3609036661.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m waterstorage = WaterStorage(\n\u001b[0m\u001b[0;32m 2\u001b[0m \u001b[0mname\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'MyStorage'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[0mmax_power\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m10\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[0mmin_power\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;36m10\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[0mroundtrip_eff\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m0.90\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: __init__() got an unexpected keyword argument 'max_storagelevel'"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"waterstorage = WaterStorage(\n",
|
|
" name='MyStorage',\n",
|
|
" max_power=10,\n",
|
|
" min_power=-10,\n",
|
|
" roundtrip_eff=0.90,\n",
|
|
" energy_density = 50 * 1e-3,\n",
|
|
" volume = 1000,\n",
|
|
" lifetime = 25,\n",
|
|
" temperature = 368, #K\n",
|
|
" min_storagelevel = 5,\n",
|
|
" max_storagelevel = 45\n",
|
|
" \n",
|
|
")\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 42,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"waterstorage.set_freq('15T')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 43,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"5"
|
|
]
|
|
},
|
|
"execution_count": 43,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"waterstorage.set_storagelevel(5)\n",
|
|
"waterstorage.storagelevel"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 44,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"160.0"
|
|
]
|
|
},
|
|
"execution_count": 44,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"waterstorage.charging_power_limit"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 45,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"100.0"
|
|
]
|
|
},
|
|
"execution_count": 45,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"waterstorage.charge(100)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 18,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"bounded_energy 15.0\n",
|
|
"new_cl 45.0\n"
|
|
]
|
|
},
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"60.0"
|
|
]
|
|
},
|
|
"execution_count": 18,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"waterstorage.charge(300)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 19,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"45.0"
|
|
]
|
|
},
|
|
"execution_count": 19,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"waterstorage.storagelevel"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 20,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# waterstorage.charge(100)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 21,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"bounded_energy 40.0\n",
|
|
"new_cl 5.0\n"
|
|
]
|
|
},
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"160.0"
|
|
]
|
|
},
|
|
"execution_count": 21,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"waterstorage.discharge(200)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 22,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"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"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 23,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"52.84691442209342"
|
|
]
|
|
},
|
|
"execution_count": 23,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"def hp_mass_flow (hp_capacity, Tsink, Tref, Cp):\n",
|
|
" return hp_capacity /(Cp*(Tsink - Tref)) \n",
|
|
"hp_mass_flow = hp_mass_flow (hp_capacity, Tsink, Tref, Cp)\n",
|
|
"hp_mass_flow"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 24,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"42.61847937265598"
|
|
]
|
|
},
|
|
"execution_count": 24,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"def process_mass_flow (demand, Tsink, Tref, Cp):\n",
|
|
" return demand /(Cp*(Tsink - Tref)) \n",
|
|
"process_mass_flow = process_mass_flow (demand, Tsink, Tref, Cp)\n",
|
|
"process_mass_flow\n",
|
|
"# What would be the difference here with using equation or a function?"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 51,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"6.0000001202836994"
|
|
]
|
|
},
|
|
"execution_count": 51,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"# charge_mass_flow = 49.874963 - 40.221745\n",
|
|
"charged_heat = (10.084152 * Cp * (142.003109- 0)) / MW_to_J_per_s\n",
|
|
"charged_heat\n",
|
|
"# 1st simulation"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 57,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"13.566135179639064"
|
|
]
|
|
},
|
|
"execution_count": 57,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"discharged_heat = 6.0000001202836994*efficiency\n",
|
|
"discharge_mass_flow = discharged_heat * MW_to_J_per_s /(Cp*(95 - 0))\n",
|
|
"discharge_mass_flow"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 49,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"6.000000181313592"
|
|
]
|
|
},
|
|
"execution_count": 49,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"charged_heat = (9.653219 * Cp * (148.342325- 0)) / MW_to_J_per_s\n",
|
|
"charged_heat\n",
|
|
"# 10th simulation"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 56,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"13.566135317629023"
|
|
]
|
|
},
|
|
"execution_count": 56,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"discharged_heat = 6.000000181313592*efficiency\n",
|
|
"discharge_mass_flow = discharged_heat * MW_to_J_per_s /(Cp*(95 - 0))\n",
|
|
"discharge_mass_flow"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"charge_mass_flow = hp_mass_flow - process_mass_flow\n",
|
|
"charged_heat = (charge_mass_flow * Cp * (Tsink - Tref)) / MW_to_J_per_s\n",
|
|
"charged_heat"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 26,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"13.566134907674918"
|
|
]
|
|
},
|
|
"execution_count": 26,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"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",
|
|
"\n",
|
|
"# energy is balanced here, mass in is smaller than mass out meaning that there should be extra inlet to ensure the water level\n",
|
|
"#This energy loss is because storage is charged with high temperature and discharged with low.\n",
|
|
"# heat loss can be neglected assuming that storage is well-insulated."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 48,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"13.566135179639064"
|
|
]
|
|
},
|
|
"execution_count": 48,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"discharged_heat = 6.0000001202836994 * efficiency #MW\n",
|
|
"discharged_heat *= MW_to_J_per_s \n",
|
|
"discharge_mass_flow = discharged_heat /(Cp*(Tstorage - Tref))\n",
|
|
"discharge_mass_flow"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 27,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# new_Tsource = (Tstorage * discharge_mass_flow + Tsource * process_mass_flow) / (discharge_mass_flow + process_mass_flow)\n",
|
|
"# new_Tsource"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 28,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# COP_new = Tsink / (Tsink - new_Tsource)\n",
|
|
"# COP_new"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 29,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"dict_keys(['name', 'id', 'max_power', 'min_power', 'modes', 'roundtrip_eff', 'volume', 'lifetime', 'temperature', 'energy_density', 'max_storage_capacity', 'max_storagelevel', 'min_storagelevel', 'freq', 'time_factor', 'storagelevel'])"
|
|
]
|
|
},
|
|
"execution_count": 29,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"waterstorage.__dict__.keys()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 30,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"50.0"
|
|
]
|
|
},
|
|
"execution_count": 30,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"# max_storage_capacity is in MWh and it should inherit MWh to MW conversion from Assets\n",
|
|
"# MW = MWh / self.time_factor\n",
|
|
"waterstorage.max_storage_capacity"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 31,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"def COP_calculation(Tsink, Tsource):\n",
|
|
" return Tsink / (Tsink - Tsource)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 32,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from numpy.polynomial import Polynomial"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 33,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"def cop_curve(Tsink, Tsource):\n",
|
|
" c0 = Tsink / (Tsink - Tsource) \n",
|
|
" return Polynomial([c0])"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 34,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/latex": [
|
|
"$x \\mapsto \\text{10.0} + \\text{5.0}\\,x + \\text{3.0}\\,x^{2}$"
|
|
],
|
|
"text/plain": [
|
|
"Polynomial([10., 5., 3.], domain=[-1, 1], window=[-1, 1])"
|
|
]
|
|
},
|
|
"execution_count": 34,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"Polynomial([10, 5, 3])"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 35,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"(-9.685230024213075, 50)"
|
|
]
|
|
},
|
|
"execution_count": 35,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"#create an heat pump object\n",
|
|
"\n",
|
|
"heatpump = Heatpump(\"heatpump1\", 50, cop_curve, 10)\n",
|
|
"heatpump.set_heat_output(50, Tsource=333, Tsink=413)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 36,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"5.1625"
|
|
]
|
|
},
|
|
"execution_count": 36,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"heatpump.get_cop(50, Tsource=333, Tsink=413)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 37,
|
|
"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",
|
|
" 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)\n",
|
|
"\n",
|
|
" new_COP = COP_calculation (Tsink, new_Tsource)\n",
|
|
" hp_load = heatpump.set_heat_output(process_demand_MW, new_COP) #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, waterstorage_level\n",
|
|
" # return new_COP, new_cl"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 38,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"ename": "TypeError",
|
|
"evalue": "unsupported operand type(s) for -: 'float' and 'NoneType'",
|
|
"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_3084/1644856237.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m test_heatpump_and_waterstorage_system(\n\u001b[0m\u001b[0;32m 2\u001b[0m \u001b[0mTsink\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;36m140\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 3\u001b[0m \u001b[0mTsource\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;36m60\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 4\u001b[0m \u001b[0mprocess_demand_MW\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;36m25\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[0me_price\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;36m150\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
|
"\u001b[1;32mC:\\Users\\SHAHLA~1\\AppData\\Local\\Temp/ipykernel_3084/1116608474.py\u001b[0m in \u001b[0;36mtest_heatpump_and_waterstorage_system\u001b[1;34m(Tsink, Tsource, process_demand_MW, e_price, waterstorage_level)\u001b[0m\n\u001b[0;32m 39\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 40\u001b[0m \u001b[0mnew_COP\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mCOP_calculation\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mTsink\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnew_Tsource\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 41\u001b[1;33m \u001b[0mhp_load\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mheatpump\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mset_heat_output\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mprocess_demand_MW\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnew_COP\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;31m#bu da hemcinin set load assetin funksiyasidir,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 42\u001b[0m \u001b[1;31m#heatpump da overwrite edilib. men evezinde yazdim ki set_heat_output\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 43\u001b[0m \u001b[1;31m#sen gor hansi funksiya sene lazimdir.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
|
"\u001b[1;32m~\\python\\Encore\\notepad.py\u001b[0m in \u001b[0;36mset_heat_output\u001b[1;34m(self, heat_output, Tsink, Tsource)\u001b[0m\n\u001b[0;32m 325\u001b[0m \u001b[1;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34mf\"Tsource '{Tsource}' can not be higher than '{Tsink}'.\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 326\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 327\u001b[1;33m \u001b[0mcop\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_cop\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mheat_output\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mheat_output\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mTsink\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mTsink\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mTsource\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mTsource\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 328\u001b[0m \u001b[0me_load\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m-\u001b[0m\u001b[0mheat_output\u001b[0m \u001b[1;33m/\u001b[0m \u001b[0mcop\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 329\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0me_load\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mheat_output\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
|
"\u001b[1;32m~\\python\\Encore\\notepad.py\u001b[0m in \u001b[0;36mget_cop\u001b[1;34m(self, heat_output, Tsink, Tsource)\u001b[0m\n\u001b[0;32m 293\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mcop_curve\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 294\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 295\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mcop_curve\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mTsink\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mTsink\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mTsource\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mTsource\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mload_perc\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 296\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 297\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mth_to_el_power\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mheat_output\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mTsink\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mTsource\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\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;32mC:\\Users\\SHAHLA~1\\AppData\\Local\\Temp/ipykernel_3084/2005226421.py\u001b[0m in \u001b[0;36mcop_curve\u001b[1;34m(Tsink, Tsource)\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mcop_curve\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mTsink\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mTsource\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;32m----> 2\u001b[1;33m \u001b[0mc0\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mTsink\u001b[0m \u001b[1;33m/\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mTsink\u001b[0m \u001b[1;33m-\u001b[0m \u001b[0mTsource\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[1;32mreturn\u001b[0m \u001b[0mPolynomial\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mc0\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: unsupported operand type(s) for -: 'float' and 'NoneType'"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"test_heatpump_and_waterstorage_system(\n",
|
|
" Tsink = 140+273, \n",
|
|
" Tsource = 60+273, \n",
|
|
" process_demand_MW = 25, \n",
|
|
" e_price = 150, \n",
|
|
" waterstorage_level = 5\n",
|
|
")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Expected behaviour: \n",
|
|
" # hp_heat_output == demand\n",
|
|
" # hp source temparture > than before\n",
|
|
" # waterstorage_level < than before\n",
|
|
" # hp cop > higher than before\n",
|
|
"hp_load"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## WaterStorage + Heatpump system"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Functional requirements for the WaterStorage + Heatpump system:\n",
|
|
"1. Goal (Funtional requirements): \n",
|
|
" * Given (context)\n",
|
|
" * price (forecast), \n",
|
|
" * source and sink temperature (provided by process), \n",
|
|
" * process heat demand, \n",
|
|
" * storage level of the water storage (temperature level)\n",
|
|
"* I want to know:\n",
|
|
" * Heat output from the heatpump (in MW)\n",
|
|
" * New storage level / temperature level\n",
|
|
" * Electricity consumption of the heatpump"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Previous examples"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 39,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# def hp_mass_flow (hp_capacity, Tsink, Tref, Cp):\n",
|
|
"# return hp_capacity /(Cp*(Tsink - Tref)) \n",
|
|
"# hp_mass_flow (31_000_000, 413, 273, 4190)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# def process_mass_flow (demand, Tsink, Tref, Cp):\n",
|
|
"# return demand /(Cp*(Tsink - Tref)) \n",
|
|
"# process_mass_flow (25_000_000, 413, 273, 4190)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# charge_mass_flow = 52 - 42 #should be written as function\n",
|
|
"# def charge_heat (charge_mass_flow, Cp, Tsink, Tref, MW_to_J_per_s):\n",
|
|
"# return (charge_mass_flow * Cp * (Tsink - Tref)) / MW_to_J_per_s\n",
|
|
"# charge_heat (10, 4190, 413, 273, 1000_000)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Tsource_new = (discharge_mass_flow * T_discharge + Tsource * source_mass_flow) / (discharge_mass_flow + source_mass_flow)\n",
|
|
"Tsource_new = (13 * 95 + 60*42) / (13+42)\n",
|
|
"Tsource_new"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# chargelevel = self.chargelevel\n",
|
|
"# max_charging = chargelevel - self.max_chargelevel\n",
|
|
"# max_discharging = chargelevel - self.min_chargelevel"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Funtionality: Set the storage level\n",
|
|
"waterstorage.storagelevel = 15\n",
|
|
"waterstorage.max_storagelevel = 23.2\n",
|
|
"waterstorage.min_storagelevel = 5\n",
|
|
"# waterstorage.max_charging = waterstorage.max_storagelevel - waterstorage.storagelevel\n",
|
|
"# waterstorage.max_discharging = waterstorage.max_storagelevel - waterstorage.min_storagelevel\n",
|
|
"waterstorage.max_discharging"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Functionality: Charge the storage\n",
|
|
"waterstorage.storage_level = 15\n",
|
|
"waterstorage.charge = 5\n",
|
|
"waterstorage.storage_level += waterstorage.charge\n",
|
|
"waterstorage.storage_level"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Functionality: Discharge the storage\n",
|
|
"waterstorage.storage_level = 15\n",
|
|
"waterstorage.discharge = 4\n",
|
|
"waterstorage.storage_level -= waterstorage.discharge\n",
|
|
"waterstorage.storage_level"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"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()"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"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.5"
|
|
},
|
|
"widgets": {
|
|
"application/vnd.jupyter.widget-state+json": {
|
|
"state": {},
|
|
"version_major": 2,
|
|
"version_minor": 0
|
|
}
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 4
|
|
}
|