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

641 lines
15 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 35,
"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\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": 36,
"metadata": {},
"outputs": [],
"source": [
"waterstorage = WaterStorage(\n",
" name='MyStorage',\n",
" max_power=10,\n",
" min_power=-10,\n",
" roundtrip_eff=0.90,\n",
" energy_density = 50 * 10e-3,\n",
" volume = 500,\n",
" lifetime = 25,\n",
" temperature = 368, #K\n",
" min_storagelevel = 5,\n",
" max_storagelevel = 23\n",
" \n",
")"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [],
"source": [
"waterstorage.set_freq('15T')"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"15"
]
},
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"waterstorage.set_storagelevel(15)\n",
"waterstorage.storagelevel"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"32.0"
]
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"waterstorage.charging_power_limit"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"32.0"
]
},
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"waterstorage.charge(100)"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"23"
]
},
"execution_count": 41,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"waterstorage.storagelevel"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.0"
]
},
"execution_count": 42,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"waterstorage.charge(100)"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"50.0"
]
},
"execution_count": 43,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"waterstorage.discharge(50)"
]
},
{
"cell_type": "code",
"execution_count": null,
"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 price > 100:\n",
" hp_load = heatpump.set_load('max')\n",
" energy_to_storage = hp_load - demand\n",
" waterstorage.charge(energy_to_storage)\n",
" waterstorage_level = waterstorage.storage_level\n",
" if price < 50:\n",
" energy_from_storage = waterstorage.discharge('max')\n",
" waterstorage_level = waterstorage.storage_level\n",
" new_Tsource = Tsource_calc(Tsource, energy_from_storage)\n",
" new_COP = cop_calc(new_Tsource, Tsink) \n",
" hp_load = heatpump.set_load(demand, new_COP)\n",
" return hp_load, waterstorage_level\n",
" \n",
"hp_load, waterstorage_level = test_heatpump_waterstorage_system(\n",
" Tsink = 373+100, \n",
" Tsoucre = 373+50, \n",
" process_demand = 20, \n",
" e_price = 150, \n",
" waterstorage_level = 0.50\n",
")\n",
"\n",
"# 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, waterstorage_level"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 44,
"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": 45,
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/plain": [
"52.84691442209342"
]
},
"execution_count": 45,
"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 (31_000_000, 413, 273, 4190)"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"42.61847937265598"
]
},
"execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
],
"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": 47,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"5.866"
]
},
"execution_count": 47,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"charge_mass_flow = 52 - 42 #can be written as a functiality\n",
"charged_heat = (charge_mass_flow * Cp * (Tsink - Tref)) / MW_to_J_per_s\n",
"charged_heat"
]
},
{
"cell_type": "code",
"execution_count": 48,
"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": 49,
"metadata": {},
"outputs": [],
"source": [
"# def source_mass_flow (demand, Tsource, Tref, Cp):\n",
"# return demand /(Cp*(Tsource - Tref)) \n",
"# source_mass_flow (25_000_000, 333, 273, 4190) "
]
},
{
"cell_type": "code",
"execution_count": 50,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2.514"
]
},
"execution_count": 50,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# efficiency = 0.7\n",
"Tstorage = 95 + 273\n",
"discharge_mass_flow = charge_mass_flow\n",
"discharged_heat = (discharge_mass_flow * Cp * (Tsource - Tref)) / MW_to_J_per_s\n",
"discharged_heat\n",
"# mass flows need to be balanced not energy\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": 56,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"66.73076923076923"
]
},
"execution_count": 56,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Tsource_new = (discharge_mass_flow * T_discharge + Tsource * source_mass_flow) / (discharge_mass_flow + source_mass_flow)\n",
"Tsource_new = (10 * 95 + 60*42) / (10+42)\n",
"Tsource_new\n"
]
},
{
"cell_type": "code",
"execution_count": 57,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"5.636745406824146"
]
},
"execution_count": 57,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Tsource_new +=273\n",
"COP_new = Tsink / (Tsink - Tsource_new)\n",
"COP_new"
]
},
{
"cell_type": "code",
"execution_count": 53,
"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": 53,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"waterstorage.__dict__.keys()"
]
},
{
"cell_type": "code",
"execution_count": 128,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"23.2"
]
},
"execution_count": 128,
"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": 129,
"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": 130,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"18.2"
]
},
"execution_count": 130,
"metadata": {},
"output_type": "execute_result"
}
],
"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": 131,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"20"
]
},
"execution_count": 131,
"metadata": {},
"output_type": "execute_result"
}
],
"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": 132,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"11"
]
},
"execution_count": 132,
"metadata": {},
"output_type": "execute_result"
}
],
"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": "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": "code",
"execution_count": null,
"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"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"state": {},
"version_major": 2,
"version_minor": 0
}
}
},
"nbformat": 4,
"nbformat_minor": 4
}