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/example.ipynb

968 lines
26 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 125,
"id": "6234aed6-ba73-43e7-b215-b180d2d864e6",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The autoreload extension is already loaded. To reload it, use:\n",
" %reload_ext autoreload\n"
]
}
],
"source": [
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "code",
"execution_count": 126,
"id": "accfef7c-7f9c-467e-91ed-1f1976eebf17",
"metadata": {},
"outputs": [],
"source": [
"from notepad import WaterStorage"
]
},
{
"cell_type": "code",
"execution_count": 143,
"id": "9e0e68f7-5b5e-4331-8048-0e010d196899",
"metadata": {},
"outputs": [],
"source": [
"tank = WaterStorage(\n",
" name='MyStorage',\n",
" max_power=10,\n",
" min_power=-10,\n",
" roundtrip_eff=0.90,\n",
" specific_heat_capacity =1.16,\n",
" volume = 1000,\n",
" lifetime = 25,\n",
" min_temperature = 55 + 273,\n",
" max_temperature = 95 + 273\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 136,
"id": "ee76c1f3-f45e-4611-9df9-b2cc602980de",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"25"
]
},
"execution_count": 136,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tank.lifetime"
]
},
{
"cell_type": "code",
"execution_count": 137,
"id": "dd188159-f3f3-4837-97ad-27385fd0cd66",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"-10"
]
},
"execution_count": 137,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tank.min_power"
]
},
{
"cell_type": "code",
"execution_count": 138,
"id": "9d3df2d7-65b4-41a5-84d6-0b0ec751013e",
"metadata": {},
"outputs": [],
"source": [
"capex_per_MW = 10_000\n",
"capex_per_MWh = 3_000\n",
"# Q_max = 50000\n",
"\n",
"tank.set_financials(\n",
" capex_per_MW,\n",
" capex_per_MWh,\n",
" 2_000,\n",
" 0,\n",
" lifetime=30\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 139,
"id": "05b6436f-401e-4fbf-bdc0-c52f4e4f1867",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2000"
]
},
"execution_count": 139,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tank.opex"
]
},
{
"cell_type": "code",
"execution_count": 142,
"id": "a7c7ef93-e8b3-403a-aedc-af786d785f20",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"14.02"
]
},
"execution_count": 142,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tank.capex/1e6"
]
},
{
"cell_type": "code",
"execution_count": 133,
"id": "16cd1fa1-09ed-43eb-a5b7-3e82f67e1641",
"metadata": {},
"outputs": [],
"source": [
"from notepad import Heatpump"
]
},
{
"cell_type": "code",
"execution_count": 59,
"id": "afce7655-b7c9-4d90-a95e-3280b2299647",
"metadata": {},
"outputs": [],
"source": [
"class Car:\n",
" def __init__(self, brand, color):\n",
" self.brand = brand\n",
" self.color = color\n",
" \n",
" def __repr__(self):\n",
" return f\"This is my {self.color} {self.brand}.\"\n",
" \n",
"mycar = Car(brand='Ferrari', color='Red')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "618829c4-42ed-4921-9ca9-4c34fc570c61",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 21,
"id": "dad3fe1f-9614-4336-8930-8234f52e6dae",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"This is my Red Ferrari."
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"mycar"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "4485c572-8554-4964-835d-8d0d1d41eb2e",
"metadata": {},
"outputs": [],
"source": [
"from pyrecoy.assets import WaterStorage"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "f41d1e57-bcd4-4c09-af8e-acc00072c1af",
"metadata": {},
"outputs": [
{
"ename": "TypeError",
"evalue": "__init__() got an unexpected keyword argument 'storage_capacity'",
"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_29716/1712525065.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m vessel = 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.70\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 'storage_capacity'"
]
}
],
"source": [
"vessel = WaterStorage(\n",
" name='MyStorage',\n",
" max_power=10,\n",
" min_power=-10,\n",
" roundtrip_eff=0.70,\n",
" storage_capacity=100\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "afaecf07-a2a8-449f-8563-f4f2d483b71c",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'vessel' is not defined",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32mC:\\Users\\SHAHLA~1\\AppData\\Local\\Temp/ipykernel_29716/4025137326.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mvessel\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;31mNameError\u001b[0m: name 'vessel' is not defined"
]
}
],
"source": [
"vessel"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "c55c89da-5115-4eb4-85fd-fe027ab50b5f",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'vessel' is not defined",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32mC:\\Users\\SHAHLA~1\\AppData\\Local\\Temp/ipykernel_29716/538738538.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 2\u001b[0m \u001b[0mcapex_per_MWh\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;36m3_000\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 4\u001b[1;33m vessel.set_financials(\n\u001b[0m\u001b[0;32m 5\u001b[0m \u001b[0mcapex_per_MW\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 6\u001b[0m \u001b[0mcapex_per_MWh\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mNameError\u001b[0m: name 'vessel' is not defined"
]
}
],
"source": [
"capex_per_MW = 10_000\n",
"capex_per_MWh = 3_000\n",
"\n",
"vessel.set_financials(\n",
" capex_per_MW,\n",
" capex_per_MWh,\n",
" 2_000,\n",
" 0,\n",
" lifetime=30\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "865222bf-57e9-43c7-80d0-f87db62c16d1",
"metadata": {},
"outputs": [],
"source": [
"10*10_000 + 100*3_000"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "470737ab-2411-4746-ab77-9457dacfe6b7",
"metadata": {},
"outputs": [],
"source": [
"vessel.capex"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "f1419aa7-306c-4966-94b8-7f2a674f3bef",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'vessel' is not defined",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32mC:\\Users\\SHAHLA~1\\AppData\\Local\\Temp/ipykernel_21184/2076975315.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mvessel\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mopex\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;31mNameError\u001b[0m: name 'vessel' is not defined"
]
}
],
"source": [
"vessel.opex"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d0a96b2c-7de4-4c8b-a1ad-af212366706a",
"metadata": {},
"outputs": [],
"source": [
"from pyrecoy.assets import HeatBuffer"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6586728b-c1e8-40b8-a06d-0937dc286096",
"metadata": {},
"outputs": [],
"source": [
"vessel = HeatBuffer(\n",
" name='MyStorage',\n",
" rated_capacity=100,\n",
" min_buffer_level_perc=0.3,\n",
" buffer_level_at_start=.5,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2ac71015-f6b8-4bcd-8fc0-c644566781e6",
"metadata": {},
"outputs": [],
"source": [
"vessel.get_soc()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2411b8a5-55c0-4a1f-a914-aa6a9a97066e",
"metadata": {},
"outputs": [],
"source": [
"vessel.set_freq('H')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "06b9093f-ac2e-401b-8808-0cb6c9d21995",
"metadata": {},
"outputs": [],
"source": [
"vessel.charge(10)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8ac8aaec-9f83-4672-803b-3393e92cea85",
"metadata": {},
"outputs": [],
"source": [
"vessel.get_soc()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fa653139-c038-49c6-b80b-4038e649f3ef",
"metadata": {},
"outputs": [],
"source": [
"vessel.chargelevel"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a5333668-b73c-4a81-a8f6-71bb44bef877",
"metadata": {},
"outputs": [],
"source": [
"def test_method(variable_name):\n",
" print(variable_name)\n",
" \n",
"test_method(5)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ee03a3af-b9d6-4cb3-ad27-cae10bc5a6b4",
"metadata": {},
"outputs": [],
"source": [
"help(vessel)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "38840a88-dff7-4d44-ba8e-6fb8fc234771",
"metadata": {},
"outputs": [],
"source": [
"help(vessel)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f75c8d8f-5586-4b45-aa13-31f4aed5c99d",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "c243d17f-dec8-48dc-829c-a2c5fec7fbbb",
"metadata": {},
"outputs": [],
"source": [
"class SchoolPerson:\n",
" \n",
" schoolpopulation = 0\n",
" \n",
" def __init__(self, name, age ):\n",
" self.name = name\n",
" self.age = age\n",
" \n",
" \n",
" SchoolPerson.schoolpopulation +=1 \n",
" print(f'Initialized person:{self.name}')\n",
" \n",
" \n",
" def tellName(self):\n",
" print(f'Name: {self.name} , age: {self.age}')\n",
" \n",
" @classmethod\n",
" def Count(cls):\n",
" print('number of people:', cls.schoolpopulation)\n",
"\n",
" \n",
"class SchoolTeacher(SchoolPerson):\n",
" def __init__(self, name, age, salary):\n",
" SchoolPerson.__init__(self, name ,age)\n",
" self.salary = salary\n",
" \n",
" def tellName(self):\n",
" print(f'Name: {self.name} , age: {self.age}, salary: {self.salary}')\n",
" super().tellName()\n",
" \n",
" @classmethod\n",
" def Count(cls):\n",
" super().Count()\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f462528b-e981-4d99-ae88-806e13e254fe",
"metadata": {},
"outputs": [],
"source": [
"c = SchoolPerson('Nazim', 30)\n",
"c.name\n",
"d = SchoolPerson('Rasim', 23)\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cd2d7a8b-25f6-4438-b0b3-9ab1a4c5a33a",
"metadata": {},
"outputs": [],
"source": [
"SchoolPerson.Count()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c937bf4b-4cd2-4e6e-9ece-31689eb55b5e",
"metadata": {},
"outputs": [],
"source": [
"f = SchoolTeacher('John', 35, 1111)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a8eb084e-d233-4225-baa7-35c290e45ffb",
"metadata": {},
"outputs": [],
"source": [
"SchoolTeacher.Count()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ddff6fb6-d01d-408b-8d08-2dc226edf07b",
"metadata": {},
"outputs": [],
"source": [
"c.__dict__"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0413f66c-9390-4444-a712-ab4e85a9ed32",
"metadata": {},
"outputs": [],
"source": [
"x = 23\n",
"\n",
"class Addition:\n",
" \n",
" x = 10\n",
" \n",
" def __init__(self, x):\n",
" self.x = x\n",
" \n",
" def addY_1(self, y):\n",
" print('Result:', self.x + y)\n",
" \n",
" @classmethod\n",
" def addY_2(cls, y):\n",
" print('Result:', cls.x + y)\n",
" \n",
" @staticmethod\n",
" def addY_3(y):\n",
" print('Result:', x + y)\n",
" \n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2114ab51-ccd7-4b41-a20e-272c8ae1a88b",
"metadata": {},
"outputs": [],
"source": [
"n = Addition(23)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "aeeb5ada-84d9-4750-b9c7-d38ee24db7fc",
"metadata": {},
"outputs": [],
"source": [
"n.addY_1(2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e103e15c-a1e5-494b-b40a-60b5702509cd",
"metadata": {},
"outputs": [],
"source": [
"# n.addY_2(2)\n",
"\n",
"n.addY_3(2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e1c04684-739a-4ff5-aedf-ebeb44cf1512",
"metadata": {},
"outputs": [],
"source": [
"t = Addition(30)\n",
"t.addY_1(2)\n",
"t.addY_2(2)\n",
"Addition.addY_2(2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "50936cf6-d267-4a74-8c99-90dc063c55a6",
"metadata": {},
"outputs": [],
"source": [
"def buterbrod(icfunksiya):\n",
" def corekle():\n",
" print('/------- \\\\')\n",
" icfunksiya()\n",
" print('\\-------//')\n",
" return corekle()\n",
"\n",
"\n",
"\n",
" \n",
"@buterbrod\n",
"def pendirli():\n",
" print('=========')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2a5f08ba-b25f-4a8f-8cbf-a72ac75cf68f",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "34cb1c1e-9466-4ef2-be5f-3009f47434f7",
"metadata": {},
"outputs": [],
"source": [
"from itertools import count\n",
"class Asset:\n",
" \"\"\"Generic class for producing/consuming assets. Specific asset classes can\n",
" inherit from this class.\n",
"\n",
" Parameters:\n",
" -----------\n",
" max_power : int/float\n",
" Maximum asset power in MW electric\n",
" min_power : int/float\n",
" Minimium asset load in MW electric\n",
"\n",
" Usage:\n",
" ------\n",
" Use the set_load and get_load methods to set and get asset status in MW.\n",
"\n",
" Convention is negative values for inputs (consumption) and positive\n",
" values for outputs (production).\n",
" \"\"\"\n",
"\n",
" _freq_to_multiplier = {\"H\": 1, \"15T\": (1 / 4), \"1T\": (1 / 60)}\n",
" _ids = count(0)\n",
"\n",
" def __init__(self, name, max_power, min_power):\n",
" if min_power > max_power:\n",
" raise ValueError(\"'min_power' can not be larger than 'max_power'.\")\n",
"\n",
" self.name = name\n",
" self.id = next(self._ids)\n",
" self.max_power = max_power\n",
" self.min_power = min_power\n",
" self.modes = {\"max\": max_power, \"min\": min_power}\n",
"\n",
" def __repr__(self):\n",
" return f\"{self.__class__.__name__}(self, max_power={self.max_power}, min_power={self.min_power})\"\n",
"\n",
" def set_load(self, load):\n",
" \"\"\"Set Asset load in MW.\n",
"\n",
" Convention is negative value for consumption and positive value\n",
" for production. Subclasses might use a different convention if\n",
" this seems more intiutive.\n",
"\n",
" Returns the load that is set in MW.\n",
" \"\"\"\n",
" if load < self.min_power or load > self.max_power:\n",
" warnings.warn(\n",
" f\"Chosen Asset load for {self.name} is out of range. \"\n",
" f\"Should be between {self.min_power} and {self.max_power}. \"\n",
" f\"Function will return boundary load level for now.\"\n",
" )\n",
" load = min(max(load, self.min_power), self.max_power)\n",
" return load\n",
"\n",
" def set_mode(self, mode):\n",
" \"\"\" \"\"\"\n",
" load = self.modes[mode]\n",
" return self.set_load(load)\n",
"\n",
" def MW_to_MWh(self, MW):\n",
" \"\"\"Performs conversion from MW to MWh using the time_factor variable.\"\"\"\n",
" return MW * self.time_factor\n",
"\n",
" def MWh_to_MW(self, MWh):\n",
" \"\"\"Performs conversion from MWh to MW using the time_factor variable.\"\"\"\n",
" return MWh / self.time_factor\n",
"\n",
" def set_freq(self, freq):\n",
" \"\"\"\n",
" Function that aligns time frequency between Model and Asset.\n",
" Can be '1T', '15T' or 'H'\n",
" The time_factor variable is used in subclasses to perform MW to MWh conversions.\n",
" \"\"\"\n",
" self.freq = freq\n",
" self.time_factor = Asset._freq_to_multiplier[freq]\n",
"\n",
" def set_financials(self, capex, opex, devex, lifetime=None, depreciate=True, salvage_value=0):\n",
" \"\"\"Set financial data of the asset.\"\"\"\n",
" self.capex = capex\n",
" self.opex = opex\n",
" self.devex = devex\n",
" self.lifetime = lifetime\n",
" self.depreciate = depreciate\n",
" self.salvage_value = salvage_value"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "81a28df0-2ed6-42f4-bd8e-22bcfc992f79",
"metadata": {},
"outputs": [],
"source": [
"class WaterStorage(Asset):\n",
" \n",
" def __init__(\n",
" self, \n",
" name,\n",
" max_power,\n",
" min_power,\n",
" roundtrip_eff,\n",
" lifetime,\n",
" power_capex, \n",
" energy_capex,\n",
" opex,\n",
" heat_demand = 23.5*1.06,\n",
" heat_st_capacity = 70, \n",
" storage_size = 22650\n",
" ):\n",
" super().__init__(name, max_power, min_power)\n",
" self.rt_eff = roundtrip_eff\n",
" self.lifetime = lifetime\n",
" self.power_capex = power_capex #Euro/kW\n",
" self.energy_capex = energy_capex #Euro/kWh\n",
" self.opex = opex\n",
" self.heat_demand = heat_demand #MW\n",
" self.heat_st_cap = heat_st_cap #kWh/m3\n",
" self.storage_size= storage_size #m3\n",
" \n",
" def __repr__(self):\n",
" return (\n",
" # f\"{self.__class__.__name__}(name={self.name}, max_power={self.max_power}, \"\n",
" # f\"min_power={self.min_power}, efficiency={self.efficiency})\"\n",
" f\"\"\"{self.__class__.__name__}(name={self.name}, max_power={self.max_power}, \n",
" min_power={self.min_power}, efficiency={self.efficiency})\"\"\"\n",
" )\n",
" \n",
" def set_capacity(self, capacity):\n",
" if not isinstance(capacity, (int, float)):\n",
" raise TypeError('Should be float')\n",
" if capacity < 0:\n",
" raise ValueError('Capacity has to be positive')\n",
" self.capacity = capacity\n",
" \n",
" def cost_function(self):\n",
" return self.heat_demand * self.power_capex * 1e6 + self.heat_st_cap * self.storage_size * self.energy_capex\n",
" \n",
" \n",
" \n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ed141f44-e508-4613-9eb8-bf7adf39e1d3",
"metadata": {},
"outputs": [],
"source": [
"s = WaterStorage\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "de204644-8b68-419f-82ee-772072b25a2e",
"metadata": {},
"outputs": [],
"source": [
"c.__dict__"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2ab516f0-3f28-41d3-ba30-0622773eed82",
"metadata": {},
"outputs": [],
"source": [
"d = Asset('Pump', 200, 20)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9e325374-f7ea-46b1-9763-c13d24f051c7",
"metadata": {},
"outputs": [],
"source": [
"d.__dict__"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9fac7681-f324-4f73-9566-0843077afca3",
"metadata": {},
"outputs": [],
"source": [
"class Eboiler(Asset):\n",
" \"\"\"Subclass for an E-boiler.\"\"\"\n",
"\n",
" def __init__(self, name, max_power, min_power=0, efficiency=0.99):\n",
" super().__init__(name, min_power=-max_power, max_power=-min_power)\n",
" self.efficiency = efficiency\n",
" self.max_thermal_output = max_power * 0.99\n",
"\n",
" def __repr__(self):\n",
" return (\n",
" f\"{self.__class__.__name__}(name={self.name}, max_power={self.max_power}, \"\n",
" f\"min_power={self.min_power}, efficiency={self.efficiency})\"\n",
" )\n",
"\n",
" def set_load(self, load):\n",
" \"\"\"Set load in MWe, returns (load, heat_output) in MWe and MWth\n",
"\n",
" Convention is negative numbers for consumption.\n",
" Inserting a positive value will return an exception.\n",
" \"\"\"\n",
"\n",
" if load > 0:\n",
" raise ValueError(\n",
" f\"Eboiler.set_load() only accepts negative numbers by convention. \"\n",
" f\"{load} was inserted.\"\n",
" )\n",
"\n",
" load = super().set_load(load)\n",
" heat_output = -load * self.efficiency\n",
" return (load, heat_output)\n",
"\n",
" def set_heat_output(self, heat_output):\n",
" \"\"\"Set heat output in MWth, returns tuple (heat_output, eload) in MW\"\"\"\n",
" load = -heat_output / self.efficiency\n",
" load, heat_output = self.set_load(load)\n",
" return heat_output, load"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "904d8541-4d1b-4d1e-a7a3-e9fe939689bb",
"metadata": {},
"outputs": [],
"source": [
"e = Eboiler('eboyul', 300)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9c5866c7-026b-41b4-b5c6-1476e82ff0ac",
"metadata": {},
"outputs": [],
"source": [
"e.__dict__"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0f9a1714-bd18-4487-9f1c-24ca0ca31473",
"metadata": {},
"outputs": [],
"source": [
"e.set_financials(300,400,500)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f135160a-484f-4cbc-8df1-cfab32195423",
"metadata": {},
"outputs": [],
"source": [
"e.__dict__"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5ae82d8a-36d1-4456-97e6-d93679b1d211",
"metadata": {},
"outputs": [],
"source": []
}
],
"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"
}
},
"nbformat": 4,
"nbformat_minor": 5
}