system_assignation/presentation.ipynb

3717 lines
871 KiB
Plaintext
Raw Normal View History

2024-03-28 10:30:54 -04:00
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "initial_id",
"metadata": {
"collapsed": true,
"ExecuteTime": {
"end_time": "2024-03-15T18:21:49.991853Z",
"start_time": "2024-03-15T18:21:40.308604500Z"
}
},
"outputs": [],
"source": [
"from geojson_creator import process_geojson\n",
"from pathlib import Path\n",
"from scripts.ep_workflow import energy_plus_workflow\n",
"from hub.imports.geometry_factory import GeometryFactory\n",
"from hub.helpers.dictionaries import Dictionaries\n",
"from hub.imports.construction_factory import ConstructionFactory\n",
"from hub.imports.usage_factory import UsageFactory\n",
"from hub.imports.weather_factory import WeatherFactory\n",
"from hub.imports.energy_systems_factory import EnergySystemsFactory\n",
"from scripts.random_assignation import call_random, residential_systems_percentage, residential_new_systems_percentage\n",
"import hub.helpers.constants as cte\n",
"from hub.imports.energy_systems.energy_system_sizing import SystemSizing\n",
"from system_simulation import SystemSimulation\n",
"from hub.helpers.monthly_values import MonthlyValues\n",
"from DistrictHeatingNetworkCreator import DistrictHeatingNetworkCreator, plot_network_graph\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 4,
"outputs": [],
"source": [
"coordinate = [45.533721353550895, -73.60218001215149]\n",
"geojson_file = process_geojson(x=coordinate[1], y=coordinate[0], diff=0.005)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-15T22:13:27.902869800Z",
"start_time": "2024-03-15T22:12:59.575900800Z"
}
},
"id": "af279e5953d738a3"
},
{
"cell_type": "code",
"execution_count": 46,
"outputs": [],
"source": [
"file_path = \"./input_files/output_buildings.geojson\""
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-07T04:22:17.955290700Z",
"start_time": "2024-03-07T04:22:17.860146900Z"
}
},
"id": "2151290f994c5e55"
},
{
"cell_type": "code",
"execution_count": 47,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"city created from ./input_files/output_buildings.geojson\n"
]
}
],
"source": [
"city = GeometryFactory('geojson',\n",
" path=file_path,\n",
" height_field='height',\n",
" year_of_construction_field='year_of_construction',\n",
" function_field='function',\n",
" function_to_hub=Dictionaries().montreal_function_to_hub_function).city\n",
"print(f'city created from {file_path}')"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-07T04:22:20.686337700Z",
"start_time": "2024-03-07T04:22:19.684778200Z"
}
},
"id": "76a49a4fa4b7e7b7"
},
{
"cell_type": "code",
"execution_count": 48,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"enrich constructions... done\n"
]
}
],
"source": [
"ConstructionFactory('nrcan', city).enrich()\n",
"print('enrich constructions... done')"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-07T04:22:35.143609Z",
"start_time": "2024-03-07T04:22:33.950471100Z"
}
},
"id": "7dde0f5014c7c7c0"
},
{
"cell_type": "code",
"execution_count": 49,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"enrich usage... done\n"
]
}
],
"source": [
"UsageFactory('nrcan', city).enrich()\n",
"print('enrich usage... done')"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-07T04:22:44.160020700Z",
"start_time": "2024-03-07T04:22:40.519589100Z"
}
},
"id": "6921c8feddc04a1c"
},
{
"cell_type": "code",
"execution_count": 50,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"enrich weather... done\n"
]
}
],
"source": [
"WeatherFactory('epw', city).enrich()\n",
"print('enrich weather... done')"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-07T04:22:49.527124100Z",
"start_time": "2024-03-07T04:22:48.593307Z"
}
},
"id": "3c93617f2675095d"
},
{
"cell_type": "code",
"execution_count": 51,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"exporting:\n",
" idf exported...\n",
"\r\n",
"C:/EnergyPlusV9-5-0\\energyplus.exe --weather \\\\Mac\\Home\\Main\\Concordia\\Repositories\\system_assignation\\hub\\data\\weather\\epw\\CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw --output-directory \\\\Mac\\Home\\Main\\Concordia\\Repositories\\system_assignation\\out_files --idd \\\\Mac\\Home\\Main\\Concordia\\Repositories\\system_assignation\\hub\\exports\\building_energy\\idf_files\\Energy+.idd --expandobjects --readvars --output-prefix Mont-Royal_ \\\\Mac\\Home\\Main\\Concordia\\Repositories\\system_assignation\\out_files\\Mont-Royal_025e05.idf\r\n"
]
}
],
"source": [
"energy_plus_workflow(city)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-07T04:24:41.598482900Z",
"start_time": "2024-03-07T04:22:52.781718100Z"
}
},
"id": "bcd081bd30056dfd"
},
{
"cell_type": "code",
"execution_count": 52,
"outputs": [],
"source": [
"roads_file = './input_files/roads/geobase_mtl.shp'"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-07T04:28:48.003487500Z",
"start_time": "2024-03-07T04:28:47.785414600Z"
}
},
"id": "6bc1cb99e3f23c4a"
},
{
"cell_type": "code",
"execution_count": 53,
"outputs": [],
"source": [
"central_plant = [45.50189527625893, -73.64679453009131]\n",
"\n",
"central_plant_longitude = central_plant[1]\n",
"central_plant_latitude = central_plant[0]"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-07T04:28:51.401333Z",
"start_time": "2024-03-07T04:28:51.162465600Z"
}
},
"id": "c116d3ce1e950a9a"
},
{
"cell_type": "code",
"execution_count": 34,
"outputs": [],
"source": [
"network_creator = DistrictHeatingNetworkCreator(\n",
" file_path,\n",
" roads_file,\n",
" central_plant_longitude,\n",
" central_plant_latitude\n",
")"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-06T22:44:28.856784800Z",
"start_time": "2024-03-06T22:44:28.650112800Z"
}
},
"id": "737f42696366245c"
},
{
"cell_type": "code",
"execution_count": 54,
"outputs": [],
"source": [
"network_graph = network_creator.run()"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-07T04:33:20.344805700Z",
"start_time": "2024-03-07T04:28:56.838736300Z"
}
},
"id": "9423327f25d546ec"
},
{
"cell_type": "code",
"execution_count": 231,
"outputs": [
{
"data": {
"text/plain": "<Figure size 1200x1200 with 1 Axes>",
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA7YAAAPGCAYAAADX2AZZAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8pXeV/AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdd3hUZf7+8XtmkhBI6CUBpEmTpjQFJPQWQkIQFRV3BUVarLuuu4q/VVl3Wcu6+lVpgohYsENISAKhh957r9JDDQmpM3N+f2SThQVCgGTOTOb9ui4uJTnM3AkBcs/zOc9jMQzDEAAAAAAAHspqdgAAAAAAAO4ExRYAAAAA4NEotgAAAAAAj0axBQAAAAB4NIotAAAAAMCjUWwBAAAAAB6NYgsAAAAA8GgUWwAAAACAR6PYAgAAAAA8GsUWANzM22+/LYvF4pLn6tq1q7p27eqS53JXdevW1dChQ82OUeItWbJEFotFP//8s9lRikXdunUVHh5udgwA8FoUWwAoRtOnT5fFYsn/4e/vrxo1aqhPnz765JNPlJqaWiTPc+LECb399tvavHlzkTxeQdLT0/X2229ryZIlhbr+ZoVm6NChCgwMLMKE11q5cqXefvttXbx4sVif51blfV18+OGH17wv72tn/fr1t/y4O3fu1Ntvv63Dhw8XQUr3cenSJf3jH/9Q27ZtVb58eZUqVUp16tTRY489prlz55odDwBgIootALjA3/72N3399deaOHGiXnjhBUnSyy+/rBYtWmjr1q1XXfv//t//U0ZGxi09/okTJzR27NhbLrbz58/X/Pnzb+nXpKena+zYsYUutu5g5cqVGjt27HWL7Z49ezRlyhTXh7rCBx98oPT09CJ7vJ07d2rs2LElqtju379frVq10ltvvaV69erpnXfe0cSJE/XMM8/o8OHDCg8P19dff212TACASXzMDgAA3qBv375q27Zt/s9ff/11LVq0SOHh4erfv7927dql0qVLS5J8fHzk41O8fz2np6erTJky8vPzK9bn8QSlSpUy9flbtmypzZs3a9KkSfrjH/9oapbiYLfb5XQ67/gxHnroIZ0+fVpLly5Vx44dr3r/W2+9pfnz58vhcBT4OJcvX1ZAQMAdZQEAuCdWbAHAJN27d9df//pXHTlyRN98803+2693j21iYqJCQkJUoUIFBQYGqnHjxhozZoyk3FHf+++/X5L09NNP54+3Tp8+XVLufbTNmzfXhg0b1LlzZ5UpUyb/117vHtvMzEy9/fbbatSokfz9/VW9enUNHDhQBw4c0OHDh1W1alVJ0tixY/Of6+233y7yz098fLw6deqkgIAAlS1bVv369dOOHTuuumbr1q0aOnSo7r77bvn7+ys4OFjPPPOMzp07l3/N22+/rVdffVWSVK9evfzMeauZ/3uPbd4I8IoVK/THP/5RVatWVUBAgB566CGdOXPmqud3Op16++23VaNGDZUpU0bdunXTzp07b+m+3Y4dO6p79+56//33C7VSv3v3bj3yyCOqVKmS/P391bZtW82ZM+eq/I8++qgkqVu3bvkf75IlS/THP/5RlStXlmEY+de/8MILslgs+uSTT/Lfdvr0aVksFk2cODH/bcnJyRo2bJiCgoLk7++v++67T1999dVV2Q4fPiyLxaJ//etf+vjjj1W/fn2VKlVKO3fuvO7HkpWVpfDwcJUvX14rV6684cf8008/afv27frrX/96TanN07t3b/Xt2/eqz4PFYtHSpUsVFRWlatWq6a677pIkHTlyRFFRUWrcuLFKly6typUr69FHH71mhTvvMZYtW6aRI0eqcuXKKleunJ566ilduHDhujmWL1+uBx54QP7+/rr77rs1Y8aMG35cAICiw4otAJjo97//vcaMGaP58+dr+PDh171mx44dCg8P17333qu//e1vKlWqlPbv368VK1ZIkpo0aaK//e1vevPNNzVixAh16tRJkvTggw/mP8a5c+fUt29fPf744/rd736noKCg6z6Xw+FQeHi4Fi5cqMcff1wvvfSSUlNTlZiYqO3bt6tnz56aOHGiRo8erYceekgDBw6UJN177703/VhTU1N19uzZa96elZV1zdu+/vprDRkyRH369NF7772n9PR0TZw4USEhIdq0aZPq1q0rKbfwHzx4UE8//bSCg4O1Y8cOff7559qxY4dWr14ti8WigQMHau/evZo5c6Y++ugjValSRZLyC/qNvPDCC6pYsaLeeustHT58WB9//LGef/55/fDDD/nXvP7663r//fcVERGhPn36aMuWLerTp48yMzNv+vm40ttvv63OnTtr4sSJBa7a7tixQx07dlTNmjX12muvKSAgQD/++KMGDBigX375RQ899JA6d+6sF198UZ988onGjBmjJk2aSMr9Orlw4YI++ugj7dixQ82bN5ckJSUlyWq1KikpSS+++GL+2ySpc+fOkqSMjAx17dpV+/fv1/PPP6969erpp59+0tChQ3Xx4kW99NJLV+X88ssvlZmZqREjRqhUqVKqVKnSNWPgGRkZioyM1Pr167VgwYL8F2euJyYmRpL0u9/97hY+q7mioqJUtWpVvfnmm7p8+bIkad26dVq5cqUef/xx3XXXXTp8+LAmTpyorl27aufOnSpTpsxVj/H888+rQoUKevvtt7Vnzx5NnDhRR44cyb9/PM/+/fv1yCOPaNiwYRoyZIimTZumoUOHqk2bNmrWrNktZwcA3AIDAFBsvvzyS0OSsW7duhteU758eaNVq1b5P3/rrbeMK/96/uijjwxJxpkzZ274GOvWrTMkGV9++eU17+vSpYshyZg0adJ139elS5f8n0+bNs2QZPz73/++5lqn02kYhmGcOXPGkGS89dZbN8xzpcWLFxuSCvwREBCQf31qaqpRoUIFY/jw4Vc9zqlTp4zy5ctf9fb09PRrnm/mzJmGJGPZsmX5b/vggw8MScahQ4euub5OnTrGkCFD8n+e93vWs2fP/I/ZMAzjD3/4g2Gz2YyLFy/m5/Hx8TEGDBhw1eO9/fbbhqSrHvNGJBnPPfecYRiG0a1bNyM4ODj/Y7re106PHj2MFi1aGJmZmflvczqdxoMPPmg0bNgw/20//fSTIclYvHjxVc+XnJxsSDImTJhgGIZhXLx40bBarcajjz5qBAUF5V/34osvGpUqVcr/+D/++GNDkvHNN9/kX5OdnW106NDBCAwMNC5dumQYhmEcOnTIkGSUK1fOSE5Ovuq5874OfvrpJyM1NdXo0qWLUaVKFWPTpk03/Ty1atXKqFChwjVvT0tLM86cOZP/IyUlJf99eZ+/kJAQw263X/Xrrvd1s2rVKkOSMWPGjGseo02bNkZ2dnb+299//31DkhEdHZ3/tjp16lzzdZecnGyUKlXKeOWVV276MQIA7gyjyABgssDAwAJ3R65QoYIkKTo6+rbvVSxVqpSefvrpm173yy+/qEqVKvkbXF3pTo8gevPNN5WYmHjNj969e191XWJioi5evKgnnnhCZ8+ezf9hs9nUrl07LV68OP/avPuSpdwR6rNnz6p9+/aSpI0bN95R3hEjRlz1MXfq1EkOh0NHjhyRJC1cuFB2u11RUVFX/brrfe4K4+2339apU6c0adKk677//PnzWrRokQYNGpS/+n327FmdO3dOffr00b59+3T8+PECn6Nq1aq65557tGzZMknSihUrZLPZ9Oqrr+r06dPat2+fpNwV25CQkPyPPy4uTsHBwXriiSfyH8vX11cvvvii0tLStHTp0que5+GHH77hinhKSop69+6t3bt3a8mSJWrZsuVNPzeXLl267s7Zb7zxhqpWrZr/Y/DgwddcM3z4cNlstqveduXXTU5Ojs6dO6cGDRqoQoUK1/26GTFihHx9ffN/Pnr0aPn4+CguLu6q65o2bZo/MSHlfr4bN26sgwcP3vRjBADcGUaRAcBkaWlpqlat2g3f/9hjj2nq1Kl69tln9dprr6lHjx4aOHCgHnnkEVmthXt9smbNmoXaKOrAgQNq3LhxsWxe1aJFC/Xs2fOat195f7Gk/HLVvXv36z5OuXLl8v///Pn
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"def plot_network_graph(network_graph, central_plant_id=1):\n",
" plt.figure(figsize=(12, 12))\n",
" pos = {node: (node[0], node[1]) for node in network_graph.nodes()}\n",
"\n",
" # Node colors based on type\n",
" node_colors = ['red' if data.get('building_id') == str(central_plant_id) else 'green' if data.get(\n",
" 'type') == 'centroid' else 'blue' for node, data in network_graph.nodes(data=True)]\n",
"\n",
" # Node sizes, larger for central plant\n",
" node_sizes = [100 if data.get('building_id') == str(central_plant_id) else 50 for node, data in\n",
" network_graph.nodes(data=True)]\n",
"\n",
" nx.draw_networkx_nodes(network_graph, pos, node_color=node_colors, node_size=node_sizes)\n",
" nx.draw_networkx_edges(network_graph, pos, edge_color='gray', width=1)\n",
"\n",
" plt.title('District Heating Network Graph')\n",
" plt.axis('off')\n",
" plt.savefig('network_graph_visualization.png', format='png', dpi=300) # Save as PNG with high dpi for clarity\n",
" plt.show()\n",
"plot_network_graph(network_graph)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-08T12:37:25.242171200Z",
"start_time": "2024-03-08T12:37:23.473287500Z"
}
},
"id": "e32bf9d2b7684f81"
},
{
"cell_type": "code",
"execution_count": 68,
"outputs": [],
"source": [
"def enrich_graph(graph, city):\n",
" \"\"\"\n",
" Enrich the graph nodes with hourly building demand data.\n",
"\n",
" :param graph: The networkx graph of the district heating network.\n",
" :param buildings: A list of building objects, each with a 'name' and 'heating_demand' attribute.\n",
" \"\"\"\n",
" for node in graph.nodes:\n",
" node_data = graph.nodes[node]\n",
" # Check if the node has a 'building_id' attribute before comparing\n",
" if 'building_id' in node_data:\n",
" for building in city.buildings:\n",
" if node_data['building_id'] == building.name:\n",
" # Assuming `building.heating_demand` is properly structured for direct assignment\n",
" graph.nodes[node][\"Demand\"] = building.heating_demand[cte.HOUR]\n",
" graph.nodes[node][\"Peack_Demand\"] = building.heating_peak_load[cte.YEAR]"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-07T05:02:30.262648Z",
"start_time": "2024-03-07T05:02:29.981569600Z"
}
},
"id": "aec54c50f6873ba2"
},
{
"cell_type": "code",
"execution_count": 69,
"outputs": [],
"source": [
"enrich_graph(network_graph, city)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-07T05:02:33.598079600Z",
"start_time": "2024-03-07T05:02:33.535428200Z"
}
},
"id": "714a25542a73d656"
},
{
"cell_type": "code",
"execution_count": 75,
"outputs": [
{
"data": {
"text/plain": " Start Node \\\n0 (293268.92232946283, 5040206.601044122) \n1 (293162.4584459267, 5040298.134698394) \n2 (293169.9422966335, 5040254.972466738) \n3 (293161.9162166267, 5040243.155704052) \n4 (293243.96496123145, 5040244.083651768) \n5 (293208.27353312843, 5040191.91032603) \n6 (293179.0032363437, 5040271.258029018) \n7 (293228.2223414392, 5040216.721843737) \n8 (293212.70831835904, 5040249.072585436) \n9 (293201.0374294459, 5040234.62735603) \n10 (293177.91918802116, 5040196.235110773) \n11 (293168.61618659477, 5040180.519320131) \n12 (293211.21706085204, 5040312.731630573) \n13 (293249.93628141866, 5040178.0515293395) \n14 (293221.9359037339, 5040305.265169374) \n15 (293247.62836591585, 5040286.946975689) \n16 (293162.5326243373, 5040344.244190009) \n17 (293274.85871539445, 5040270.178231545) \n18 (293221.1012564584, 5040259.169113723) \n19 (293258.2672356481, 5040190.475701797) \n20 (293237.5724254025, 5040294.591521784) \n21 (293221.0543914453, 5040205.772851501) \n22 (293263.9478932525, 5040277.498572837) \n23 (293193.935307871, 5040223.606890397) \n24 (293186.26851059805, 5040282.301174366) \n25 (293185.13387576357, 5040207.2769374205) \n26 (293237.28612816025, 5040233.025292898) \n27 (293193.65639875695, 5040323.624066331) \n28 (293173.44689440983, 5040336.995190537) \n29 (293276.818447755, 5040218.71502952) \n30 (293202.12567603646, 5040180.27465022) \n31 (293328.35617741547, 5040229.762923518) \n32 (293251.93105040304, 5040217.926054459) \n33 (293251.93105040304, 5040217.926054459) \n34 (293171.90206806763, 5040312.19278805) \n35 (293171.90206806763, 5040312.19278805) \n36 (293186.20481946884, 5040244.159450427) \n37 (293186.20481946884, 5040244.159450427) \n38 (293178.29597659543, 5040232.264736303) \n39 (293253.3895766028, 5040258.911978145) \n40 (293253.3895766028, 5040258.911978145) \n41 (293226.4958520454, 5040179.7648042375) \n42 (293196.49133223895, 5040259.63012429) \n43 (293244.0825581944, 5040206.150707917) \n44 (293196.59516456636, 5040259.786285674) \n45 (293186.35704876215, 5040244.388399713) \n46 (293161.56838219793, 5040207.106826794) \n47 (293152.78058224276, 5040194.16586493) \n48 (293198.74294034916, 5040294.162240376) \n49 (293232.9154049299, 5040189.396266925) \n\n End Node Length \n0 (293251.93105040304, 5040217.926054459) 20.419584 \n1 (293171.90206806763, 5040312.19278805) 16.935521 \n2 (293186.20481946884, 5040244.159450427) 19.529234 \n3 (293178.29597659543, 5040232.264736303) 19.670021 \n4 (293253.3895766028, 5040258.911978145) 17.569936 \n5 (293226.4958520454, 5040179.7648042375) 21.899009 \n6 (293196.49133223895, 5040259.63012429) 21.000992 \n7 (293244.0825581944, 5040206.150707917) 19.060309 \n8 (293196.59516456636, 5040259.786285674) 19.349860 \n9 (293186.35704876215, 5040244.388399713) 17.629281 \n10 (293161.56838219793, 5040207.106826794) 19.635250 \n11 (293152.78058224276, 5040194.16586493) 20.904415 \n12 (293198.74294034916, 5040294.162240376) 22.370202 \n13 (293232.9154049299, 5040189.396266925) 20.455154 \n14 (293209.58491002093, 5040286.879069806) 22.149395 \n15 (293236.59445823065, 5040269.586650846) 20.570075 \n16 (293150.67694876884, 5040326.42836015) 21.400020 \n17 (293263.5810838301, 5040252.434440949) 21.024440 \n18 (293230.2752063758, 5040273.603052741) 17.102630 \n19 (293241.2117340568, 5040201.843517671) 20.496765 \n20 (293225.9712000135, 5040276.338601143) 21.627703 \n21 (293236.8247611614, 5040195.261600439) 18.952334 \n22 (293252.495689268, 5040259.480116727) 21.349888 \n23 (293179.0986062601, 5040233.471872488) 17.817003 \n24 (293195.6375827925, 5040296.248286495) 16.801829 \n25 (293168.8711824724, 5040218.090067068) 19.529438 \n26 (
"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>Start Node</th>\n <th>End Node</th>\n <th>Length</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>(293268.92232946283, 5040206.601044122)</td>\n <td>(293251.93105040304, 5040217.926054459)</td>\n <td>20.419584</td>\n </tr>\n <tr>\n <th>1</th>\n <td>(293162.4584459267, 5040298.134698394)</td>\n <td>(293171.90206806763, 5040312.19278805)</td>\n <td>16.935521</td>\n </tr>\n <tr>\n <th>2</th>\n <td>(293169.9422966335, 5040254.972466738)</td>\n <td>(293186.20481946884, 5040244.159450427)</td>\n <td>19.529234</td>\n </tr>\n <tr>\n <th>3</th>\n <td>(293161.9162166267, 5040243.155704052)</td>\n <td>(293178.29597659543, 5040232.264736303)</td>\n <td>19.670021</td>\n </tr>\n <tr>\n <th>4</th>\n <td>(293243.96496123145, 5040244.083651768)</td>\n <td>(293253.3895766028, 5040258.911978145)</td>\n <td>17.569936</td>\n </tr>\n <tr>\n <th>5</th>\n <td>(293208.27353312843, 5040191.91032603)</td>\n <td>(293226.4958520454, 5040179.7648042375)</td>\n <td>21.899009</td>\n </tr>\n <tr>\n <th>6</th>\n <td>(293179.0032363437, 5040271.258029018)</td>\n <td>(293196.49133223895, 5040259.63012429)</td>\n <td>21.000992</td>\n </tr>\n <tr>\n <th>7</th>\n <td>(293228.2223414392, 5040216.721843737)</td>\n <td>(293244.0825581944, 5040206.150707917)</td>\n <td>19.060309</td>\n </tr>\n <tr>\n <th>8</th>\n <td>(293212.70831835904, 5040249.072585436)</td>\n <td>(293196.59516456636, 5040259.786285674)</td>\n <td>19.349860</td>\n </tr>\n <tr>\n <th>9</th>\n <td>(293201.0374294459, 5040234.62735603)</td>\n <td>(293186.35704876215, 5040244.388399713)</td>\n <td>17.629281</td>\n </tr>\n <tr>\n <th>10</th>\n <td>(293177.91918802116, 5040196.235110773)</td>\n <td>(293161.56838219793, 5040207.106826794)</td>\n <td>19.635250</td>\n </tr>\n <tr>\n <th>11</th>\n <td>(293168.61618659477, 5040180.519320131)</td>\n <td>(293152.78058224276, 5040194.16586493)</td>\n <td>20.904415</td>\n </tr>\n <tr>\n <th>12</th>\n <td>(293211.21706085204, 5040312.731630573)</td>\n <td>(293198.74294034916, 5040294.162240376)</td>\n <td>22.370202</td>\n </tr>\n <tr>\n <th>13</th>\n <td>(293249.93628141866, 5040178.0515293395)</td>\n <td>(293232.9154049299, 5040189.396266925)</td>\n <td>20.455154</td>\n </tr>\n <tr>\n <th>14</th>\n <td>(293221.9359037339, 5040305.265169374)</td>\n <td>(293209.58491002093, 5040286.879069806)</td>\n <td>22.149395</td>\n </tr>\n <tr>\n <th>15</th>\n <td>(293247.62836591585, 5040286.946975689)</td>\n <td>(293236.59445823065, 5040269.586650846)</td>\n <td>20.570075</td>\n </tr>\n <tr>\n <th>16</th>\n <td>(293162.5326243373, 5040344.244190009)</td>\n <td>(293150.67694876884, 5040326.42836015)</td>\n <td>21.400020</td>\n </tr>\n <tr>\n <th>17</th>\n <td>(293274.85871539445, 5040270.178231545)</td>\n <td>(293263.5810838301, 5040252.434440949)</td>\n <td>21.024440</td>\n </tr>\n <tr>\n <th>18</th>\n <td>(293221.1012564584, 5040259.169113723)</td>\n <td>(293230.2752063758, 5040273.603052741)</td>\n <td>17.102630</td>\n </tr>\n <tr>\n <th>19</th>\n <td>(293258.2672356481, 5040190.475701797)</td>\n <td>(293241.2117340568, 5040201.843517671)</td>\n <td>20.496765</td>\n </tr>\n <tr>\n <th>20</th>\n <td>(293237.5724254025, 5040294.591521784)</
},
"execution_count": 75,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"edges_data = [(u, v, attrs['weight']) for u, v, attrs in network_graph.edges(data=True)]\n",
"\n",
"# Creating a DataFrame\n",
"edges_df = pd.DataFrame(edges_data, columns=['Start Node', 'End Node', 'Length'])\n",
"\n",
"edges_df.head(50)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-07T05:08:59.648101700Z",
"start_time": "2024-03-07T05:08:59.425424800Z"
}
},
"id": "2a9aff199c7e0afb"
},
{
"cell_type": "code",
"execution_count": 88,
"outputs": [
{
"data": {
"text/plain": "67"
},
"execution_count": 88,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"network_graph.number_of_nodes()"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-07T05:36:47.803538200Z",
"start_time": "2024-03-07T05:36:47.772283Z"
}
},
"id": "45264a34288ee52a"
},
{
"cell_type": "code",
"execution_count": 87,
"outputs": [
{
"data": {
"text/plain": "66"
},
"execution_count": 87,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"network_graph.number_of_edges()"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-07T05:36:44.355784700Z",
"start_time": "2024-03-07T05:36:44.073615700Z"
}
},
"id": "8e39fa467979f701"
},
{
"cell_type": "code",
"execution_count": 93,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'str'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n",
"<class 'NoneType'>\n"
]
}
],
"source": [
"for node, data in network_graph.nodes(data=True):\n",
" print(type(data.get('building_id')))"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-07T05:50:22.435138200Z",
"start_time": "2024-03-07T05:50:22.084297200Z"
}
},
"id": "a99dc335bee49b62"
},
{
"cell_type": "code",
"execution_count": 95,
"outputs": [],
"source": [
"import networkx as nx\n",
"from collections import deque\n",
"\n",
"def label_graph_elements(network_graph, central_plant_id=\"1\"):\n",
" # Initialize all nodes and edges with solver_name '0' as placeholder\n",
" nx.set_node_attributes(network_graph, '0', 'solver_name')\n",
" nx.set_edge_attributes(network_graph, '0', 'solver_name')\n",
"\n",
" # Find the central plant node\n",
" central_plant_node = None\n",
" for node, data in network_graph.nodes(data=True):\n",
" if data.get('building_id') == central_plant_id:\n",
" central_plant_node = node\n",
" break\n",
"\n",
" if central_plant_node is None:\n",
" print(\"Central plant node not found.\")\n",
" return\n",
"\n",
" # BFS to label nodes and edges\n",
" queue = deque([central_plant_node])\n",
" visited = {central_plant_node}\n",
" network_graph.nodes[central_plant_node]['solver_name'] = '1' # Central plant labeled as '1'\n",
" solver_name_counter = 2 # Start labeling from '2' for other nodes\n",
"\n",
" while queue:\n",
" current_node = queue.popleft()\n",
" for neighbor in network_graph.neighbors(current_node):\n",
" if neighbor not in visited:\n",
" network_graph.nodes[neighbor]['solver_name'] = str(solver_name_counter)\n",
" visited.add(neighbor)\n",
" queue.append(neighbor)\n",
" # Label the edge connecting these nodes\n",
" network_graph[current_node][neighbor]['solver_name'] = str(solver_name_counter)\n",
" solver_name_counter += 1\n",
"\n",
"# Assume network_graph is your network graph object\n",
"label_graph_elements(network_graph)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-07T05:50:56.983642800Z",
"start_time": "2024-03-07T05:50:56.686763400Z"
}
},
"id": "195ea4ca176687c5"
},
{
"cell_type": "code",
"execution_count": 97,
"outputs": [
{
"data": {
"text/plain": "<Figure size 640x480 with 1 Axes>",
"image/png": "iVBORw0KGgoAAAANSUhEUgAAApQAAAHzCAYAAACe1o1DAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8pXeV/AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdd3hUZfbA8e+dkkmvBAKBEKRLaIIgXYpYwYYgovkJKrqKu1hwUVBXEBcRsa6CYgEp0kRBVJQOgiBRICBFUEgIhIT0OvX+/ggzJGQmhWQmhfN5Hh+dO/fe950MmHPfco6iqqqKEEIIIYQQl0lT0x0QQgghhBB1mwSUQgghhBCiSiSgFEIIIYQQVSIBpRBCCCGEqBIJKIUQQgghRJVIQCmEEEIIIapEAkohhBBCCFElElAKIYQQQogqkYBSCCGEEEJUiQSUQgghhBCiSiSgFEIIIYQQVSIBpRBCCCGEqBIJKIUQQgghRJVIQCmEEEIIIapEAkohhBBCCFElElAKIYQQQogqkYBSCCGEEEJUiQSUQgghhBCiSiSgFEIIIYQQVSIBpRBCCCGEqBIJKIUQQgghRJVIQCmEEEIIIapEAkohhBBCCFElElAKIYQQQogqkYBSCCGEEEJUiQSUQgghhBCiSiSgFEIIIYQQVSIBpRBCCCGEqB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amk5jofpRVCCCFE/SQBZRUlJCTQpUsXAG699Va6dOlCly5dSE5O5t133yUxMZGXX3651HVNQ3yZdGM7Jg5pw9HkHOKTsohPyiI114jRbMWg1xLub6BjZBAdI4NoGxFQ4Y0uJovV5XuKzgsAv/Y
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import matplotlib.pyplot as plt\n",
"\n",
"def plot_network_with_labels(network_graph):\n",
" pos = {node: (node[0], node[1]) for node in network_graph.nodes()}\n",
" node_labels = nx.get_node_attributes(network_graph, 'solver_name')\n",
" edge_labels = nx.get_edge_attributes(network_graph, 'solver_name')\n",
"\n",
" nx.draw(network_graph, pos, with_labels=False, node_size=500)\n",
" nx.draw_networkx_labels(network_graph, pos, labels=node_labels)\n",
" nx.draw_networkx_edge_labels(network_graph, pos, edge_labels=edge_labels)\n",
" \n",
" plt.show()\n",
"\n",
"# After labeling the graph\n",
"plot_network_with_labels(network_graph)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-07T05:52:16.833966500Z",
"start_time": "2024-03-07T05:52:16.369710200Z"
}
},
"id": "a465404806ec0c74"
},
{
"cell_type": "code",
"execution_count": 100,
"outputs": [
{
"data": {
"text/plain": "array([[0. ],\n [0. ],\n [0. ],\n [0. ],\n [0. ],\n [0. ],\n [0.1783932 ],\n [0. ],\n [0.21754281],\n [0. ],\n [0.16469595],\n [0. ],\n [0.19665275],\n [0. ],\n [0.16435554],\n [0. ],\n [0.17640576],\n [0. ],\n [0.22657272],\n [0. ],\n [0.22139321],\n [0. ],\n [0.19046172],\n [0. ],\n [0.22496429],\n [0. ],\n [0.16040858],\n [0. ],\n [0.17852813],\n [0. ],\n [0. ],\n [0. ],\n [0.16579267],\n [0. ],\n [0.15764918],\n [0. ],\n [0.20921297],\n [0. ],\n [0.21256793],\n [0. ],\n [0.17568882],\n [0. ],\n [0.1769251 ],\n [0.17564162],\n [0. ],\n [0.16034261],\n [0. ],\n [0.16133044],\n [0. ],\n [0.18052214],\n [0. ],\n [0.16037667],\n [0. ],\n [0.16050263],\n [0. ],\n [0.22199958],\n [0. ],\n [0.16063176],\n [0. ],\n [0.17139641],\n [0. ],\n [0.26400758],\n [0. ],\n [0. ],\n [0.16062107],\n [0.16900195],\n [0.15725743]])"
},
"execution_count": 100,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import numpy as np\n",
"\n",
"# Assuming your network_graph object is ready and has the necessary attributes\n",
"\n",
"# Sort nodes by their solver_name attribute to ensure iteration is in order\n",
"sorted_nodes = sorted(network_graph.nodes(data=True), key=lambda x: int(x[1]['solver_name']))\n",
"\n",
"# Create the demand matrix\n",
"num_nodes = len(sorted_nodes)\n",
"demand_matrix = np.zeros((num_nodes, 1))\n",
"\n",
"# Fill the matrix with peak demand values if available, else leave as zero\n",
"for idx, (node, data) in enumerate(sorted_nodes):\n",
" demand_matrix[idx] = data.get(\"Peack_Demand\", 0)\n",
" demand_matrix[idx] = demand_matrix[idx] / 4200 / 25\n",
"# The demand_matrix is now populated based on your specifications\n",
"demand_matrix"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-07T06:06:03.399775200Z",
"start_time": "2024-03-07T06:06:03.207057500Z"
}
},
"id": "da78ad2e3a41fc96"
},
{
"cell_type": "code",
"execution_count": 107,
"outputs": [],
"source": [
"import numpy as np\n",
"import networkx as nx\n",
"\n",
"# Assuming network_graph is your undirected graph from the DistrictHeatingNetworkCreator class\n",
"# Convert the undirected graph to a directed graph\n",
"directed_graph = network_graph\n",
"\n",
"# Sort nodes by their 'solver_name'\n",
"sorted_nodes = sorted(directed_graph.nodes(data=True), key=lambda x: int(x[1]['solver_name']))\n",
"\n",
"# Sort edges based on the 'solver_name' of the nodes they connect\n",
"# This approach assumes that all nodes have a 'solver_name' attribute and it is unique and sequential\n",
"sorted_edges = sorted(directed_graph.edges(data=False), key=lambda x: (int(directed_graph.nodes[x[0]]['solver_name']), int(directed_graph.nodes[x[1]]['solver_name'])))\n",
"\n",
"# Initialize the incidence matrix\n",
"num_nodes = len(sorted_nodes)\n",
"num_edges = len(sorted_edges)\n",
"incidence_matrix = np.zeros((num_nodes, num_edges))\n",
"\n",
"# Populate the incidence matrix\n",
"for edge_idx, (u, v) in enumerate(sorted_edges):\n",
" u_idx = next(idx for idx, (node_id, _) in enumerate(sorted_nodes) if node_id == u)\n",
" v_idx = next(idx for idx, (node_id, _) in enumerate(sorted_nodes) if node_id == v)\n",
" \n",
" incidence_matrix[u_idx, edge_idx] = -1 # Source node\n",
" incidence_matrix[v_idx, edge_idx] = 1 # Target node\n",
"\n",
"# Now incidence_matrix is ready and populated as per your requirements\n"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-07T06:17:51.118962800Z",
"start_time": "2024-03-07T06:17:50.962826900Z"
}
},
"id": "d6f3251012a48716"
},
{
"cell_type": "code",
"execution_count": 108,
"outputs": [
{
"data": {
"text/plain": "66"
},
"execution_count": 108,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"directed_graph.number_of_edges()"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-07T06:17:54.519856Z",
"start_time": "2024-03-07T06:17:54.251735500Z"
}
},
"id": "b0dcdf2183910b29"
},
{
"cell_type": "code",
"execution_count": 109,
"outputs": [
{
"data": {
"text/plain": "array([[-1., 0., 0., ..., 0., 0., 0.],\n [ 1., -1., 0., ..., 0., 0., 0.],\n [ 0., 1., 1., ..., 0., 0., 0.],\n ...,\n [ 0., 0., 0., ..., -1., 0., 0.],\n [ 0., 0., 0., ..., 0., -1., 0.],\n [ 0., 0., 0., ..., 0., 0., -1.]])"
},
"execution_count": 109,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"incidence_matrix"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-07T06:17:56.606008500Z",
"start_time": "2024-03-07T06:17:56.542750400Z"
}
},
"id": "cf9b2c4967e3f2fb"
},
{
"cell_type": "code",
"execution_count": 110,
"outputs": [
{
"data": {
"text/plain": "array([[ 5.70184321],\n [ 5.70184321],\n [-3.93235405],\n [ 3.75396085],\n [-1.76948917],\n [ 1.55194636],\n [ 3.5892649 ],\n [-0.1783932 ],\n [ 1.35529361],\n [-0.21754281],\n [ 3.42490936],\n [-0.16469595],\n [ 1.17888785],\n [-0.19665275],\n [ 3.19833664],\n [-0.16435554],\n [ 0.95749464],\n [-0.17640576],\n [ 3.00787491],\n [-0.22657272],\n [ 0.73253034],\n [-0.22139321],\n [ 2.84746634],\n [-0.19046172],\n [ 0.55400221],\n [-0.22496429],\n [-0.16040858],\n [ 0.38820955],\n [-0.17852813],\n [-1.57722322],\n [ 1.41957404],\n [-1.27024312],\n [ 1.06103015],\n [ 0.17564162],\n [-0.16579267],\n [ 1.24388522],\n [-0.15764918],\n [ 0.88410506],\n [-0.20921297],\n [-0.21256793],\n [ 1.08354261],\n [-0.17568882],\n [ 0.72277462],\n [-0.1769251 ],\n [-0.17564162],\n [ 0.90302046],\n [-0.16034261],\n [ 0.56239794],\n [-0.16133044],\n [ 0.74251784],\n [-0.18052214],\n [ 0.34039836],\n [-0.16037667],\n [ 0.58188607],\n [-0.16050263],\n [ 0.16900195],\n [-0.22199958],\n [ 0.31787849],\n [-0.16063176],\n [-0.17139641],\n [ 0.15725743],\n [-0.26400758],\n [-0.16900195],\n [-0.16062107],\n [-0.16900195],\n [-0.15725743]])"
},
"execution_count": 110,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Deleting the first row from both the demand matrix and the incidence matrix\n",
"modified_demand_matrix_after_deletion = np.delete(demand_matrix, 0, axis=0)\n",
"modified_incidence_matrix_after_deletion = np.delete(incidence_matrix, 0, axis=0)\n",
"\n",
"# Attempting to solve the equation modified_incidence_matrix * [m] = modified_demand_matrix\n",
"m_solution, residuals, rank, s = np.linalg.lstsq(modified_incidence_matrix_after_deletion, modified_demand_matrix_after_deletion, rcond=None)\n",
"\n",
"m_solution"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-07T06:23:18.773672Z",
"start_time": "2024-03-07T06:23:18.164639900Z"
}
},
"id": "f91e518a7ddaf46f"
},
{
"cell_type": "code",
"execution_count": 113,
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\majidr\\AppData\\Local\\Temp\\ipykernel_8776\\646369358.py:23: MatplotlibDeprecationWarning: Unable to determine Axes to steal space for Colorbar. Using gca(), but will raise in the future. Either provide the *cax* argument to use as the Axes for the Colorbar, provide the *ax* argument to steal space from it, or add *mappable* to an Axes.\n",
" plt.colorbar(plt.cm.ScalarMappable(cmap=plt.cm.viridis), label='Mass Flow Rate Peak')\n"
]
},
{
"data": {
"text/plain": "<Figure size 640x480 with 2 Axes>",
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAf8AAAGTCAYAAAAmxxufAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8pXeV/AAAACXBIWXMAAA9hAAAPYQGoP6dpAAC580lEQVR4nOydd3gUVReH39m+6QkpBBJI6L1IEwGxoNiw94LSRFBpioIFxQIKqIB0ELF9dkUBRRFEkCa9dxJCSyM92Toz3x+bLAmdZDfZJPd9nn107s7ce4fd7Jl77jm/I6mqqiIQCAQCgaDaoKnoCQgEAoFAIChfhPEXCAQCgaCaIYy/QCAQCATVDGH8BQKBQCCoZgjjLxAIBAJBNUMYf4FAIBAIqhnC+AsEAoFAUM0Qxl8gEAgEgmqGMP4CgUAgEFQzhPEXCAQCgaCaIYy/QCAQCASXyapVq+jVqxe1atVCkiQWLlx4yWtWrlzJVVddhdFopEGDBixYsMDr87wUwvgLBAKBQHCZ5Ofn07p1a6ZPn35Z5yckJHD77bdz/fXXs23bNoYNG0b//v35448/vDzTiyOJwj4CgUAgEFw5kiTx888/c/fdd1/wnJdffpklS5awa9cud9vDDz9MVlYWS5cuLYdZnh9dhY0sEAgEAkEZsFqt2O32MvejqiqSJ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cb0oSzZvVxqZKJObYCQo3eUVVb8NvW0qmEn41FINJFOgRCAQCX0Apo9tfiPz4GLKqkpTnwKST3EF1dqsdrU6LLKtEx0cSEhlEpk1mW7qFhFwHigo6DdQJ0BPvAT39zNSSqYRPT+xNXHPvphJ6EyE7LBAIqhplr+onjL9P4VRUnAroihmpiJg
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Assigning the 'mass_flow_rate_peak' attribute to edges based on the values from m_solution\n",
"for idx, (u, v, data) in enumerate(sorted(network_graph.edges(data=True), key=lambda x: int(x[2]['solver_name']))):\n",
" network_graph[u][v]['mass_flow_rate_peak'] = abs(m_solution[idx][0])\n",
"\n",
"# Plotting the network_graph with a contour of colors based on the 'mass_flow_rate_peak' values\n",
"import matplotlib.pyplot as plt\n",
"import networkx as nx\n",
"\n",
"pos = {node: (node[0], node[1]) for node in network_graph.nodes()}\n",
"\n",
"# Edges are colored based on their 'mass_flow_rate_peak' attribute\n",
"edge_colors = [network_graph[u][v]['mass_flow_rate_peak'] for u, v in network_graph.edges()]\n",
"\n",
"# Drawing nodes\n",
"nx.draw_networkx_nodes(network_graph, pos, node_size=50, node_color='skyblue', alpha=0.6)\n",
"\n",
"# Drawing edges with mass flow rate as colors\n",
"nx.draw_networkx_edges(network_graph, pos, edge_color=edge_colors, edge_cmap=plt.cm.viridis, width=2)\n",
"\n",
"# Drawing labels\n",
"#nx.draw_networkx_labels(network_graph, pos, font_size=12, font_family=\"sans-serif\")\n",
"\n",
"plt.colorbar(plt.cm.ScalarMappable(cmap=plt.cm.viridis), label='Mass Flow Rate Peak')\n",
"plt.axis('off')\n",
"plt.show()"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-07T06:28:41.711114200Z",
"start_time": "2024-03-07T06:28:41.125355100Z"
}
},
"id": "3c652682edecdd66"
},
{
"cell_type": "code",
"execution_count": 130,
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"# Constants for the calculation\n",
"rho = 997 # Density of water at room temperature in kg/m^3\n",
"v = 1.5 # Design velocity in m/s\n",
"a = np.pi * rho * v\n",
"\n",
"# Iterate over each edge in the network_graph, ordered by 'solver_name'\n",
"for idx, (u, v, data) in enumerate(sorted(network_graph.edges(data=True), key=lambda x: int(network_graph[x[0]][x[1]]['solver_name']))):\n",
" # Convert mass_flow_rate_peak to float to ensure it's a scalar numerical value\n",
" mass_flow_rate_peak = abs(float(data['mass_flow_rate_peak']))\n",
"\n",
" # Calculate the diameter of the pipe based on the mass flow rate as a scalar operation\n",
" diameter = (4 * mass_flow_rate_peak / a) ** 0.5\n",
"\n",
" # Assign the calculated diameter back to the edge in the network_graph\n",
" network_graph[u][v]['diameter'] = diameter * 1000"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-07T14:25:45.080072Z",
"start_time": "2024-03-07T14:25:44.689426300Z"
}
},
"id": "69950bc72be9e177"
},
{
"cell_type": "code",
"execution_count": 131,
"outputs": [
{
"data": {
"text/plain": " Edge Solver Name Start Node Solver Name End Node Solver Name Diameter (m) \\\n0 2 1 2 69.673798 \n1 3 2 3 69.673798 \n2 4 4 3 57.861296 \n3 5 5 3 56.533610 \n4 6 4 6 38.813768 \n.. ... ... ... ... \n61 63 63 59 14.992362 \n62 64 61 64 11.995206 \n63 65 65 61 11.694000 \n64 66 66 63 11.995206 \n65 67 67 64 11.570908 \n\n Length (m) \n0 16.224851 \n1 57.211407 \n2 21.522844 \n3 35.381202 \n4 19.900368 \n.. ... \n61 4.300275 \n62 18.471603 \n63 17.817003 \n64 21.400020 \n65 19.529438 \n\n[66 rows x 5 columns]",
"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>Edge Solver Name</th>\n <th>Start Node Solver Name</th>\n <th>End Node Solver Name</th>\n <th>Diameter (m)</th>\n <th>Length (m)</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>2</td>\n <td>1</td>\n <td>2</td>\n <td>69.673798</td>\n <td>16.224851</td>\n </tr>\n <tr>\n <th>1</th>\n <td>3</td>\n <td>2</td>\n <td>3</td>\n <td>69.673798</td>\n <td>57.211407</td>\n </tr>\n <tr>\n <th>2</th>\n <td>4</td>\n <td>4</td>\n <td>3</td>\n <td>57.861296</td>\n <td>21.522844</td>\n </tr>\n <tr>\n <th>3</th>\n <td>5</td>\n <td>5</td>\n <td>3</td>\n <td>56.533610</td>\n <td>35.381202</td>\n </tr>\n <tr>\n <th>4</th>\n <td>6</td>\n <td>4</td>\n <td>6</td>\n <td>38.813768</td>\n <td>19.900368</td>\n </tr>\n <tr>\n <th>...</th>\n <td>...</td>\n <td>...</td>\n <td>...</td>\n <td>...</td>\n <td>...</td>\n </tr>\n <tr>\n <th>61</th>\n <td>63</td>\n <td>63</td>\n <td>59</td>\n <td>14.992362</td>\n <td>4.300275</td>\n </tr>\n <tr>\n <th>62</th>\n <td>64</td>\n <td>61</td>\n <td>64</td>\n <td>11.995206</td>\n <td>18.471603</td>\n </tr>\n <tr>\n <th>63</th>\n <td>65</td>\n <td>65</td>\n <td>61</td>\n <td>11.694000</td>\n <td>17.817003</td>\n </tr>\n <tr>\n <th>64</th>\n <td>66</td>\n <td>66</td>\n <td>63</td>\n <td>11.995206</td>\n <td>21.400020</td>\n </tr>\n <tr>\n <th>65</th>\n <td>67</td>\n <td>67</td>\n <td>64</td>\n <td>11.570908</td>\n <td>19.529438</td>\n </tr>\n </tbody>\n</table>\n<p>66 rows × 5 columns</p>\n</div>"
},
"execution_count": 131,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"\n",
"# Placeholder for edges data\n",
"edges_data = []\n",
"\n",
"# Iterate over each edge in the network_graph, assuming each has a 'solver_name', 'diameter', and 'length'\n",
"for (u, v, data) in sorted(network_graph.edges(data=True), key=lambda x: int(network_graph.edges[x[0], x[1]]['solver_name'])):\n",
" # Assuming 'solver_name' for nodes u and v can be accessed directly or computed\n",
" u_solver_name = network_graph.nodes[u]['solver_name']\n",
" v_solver_name = network_graph.nodes[v]['solver_name']\n",
" \n",
" # Append edge data\n",
" edges_data.append({\n",
" 'Edge Solver Name': data['solver_name'],\n",
" 'Start Node Solver Name': u_solver_name,\n",
" 'End Node Solver Name': v_solver_name,\n",
" 'Diameter (m)': data['diameter'],\n",
" 'Length (m)': data['weight']\n",
" })\n",
"\n",
"# Create DataFrame\n",
"edges_df = pd.DataFrame(edges_data)\n",
"\n",
"# Display the DataFrame\n",
"edges_df"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-07T14:25:46.847223200Z",
"start_time": "2024-03-07T14:25:46.548312300Z"
}
},
"id": "84bf3b6bf721543e"
},
{
"cell_type": "code",
"execution_count": 133,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\\begin{tabular}{lllrr}\n",
"\\toprule\n",
"Edge Solver Name & Start Node Solver Name & End Node Solver Name & Diameter (m) & Length (m) \\\\\n",
"\\midrule\n",
"2 & 1 & 2 & 69.673798 & 16.224851 \\\\\n",
"3 & 2 & 3 & 69.673798 & 57.211407 \\\\\n",
"4 & 4 & 3 & 57.861296 & 21.522844 \\\\\n",
"5 & 5 & 3 & 56.533610 & 35.381202 \\\\\n",
"6 & 4 & 6 & 38.813768 & 19.900368 \\\\\n",
"7 & 7 & 4 & 36.349648 & 17.569936 \\\\\n",
"8 & 5 & 8 & 55.279564 & 45.860989 \\\\\n",
"9 & 9 & 5 & 12.323980 & 20.419584 \\\\\n",
"10 & 6 & 10 & 33.968670 & 31.976183 \\\\\n",
"11 & 11 & 6 & 13.609251 & 20.570075 \\\\\n",
"12 & 8 & 12 & 53.999084 & 31.709748 \\\\\n",
"13 & 13 & 8 & 11.841407 & 21.899009 \\\\\n",
"14 & 10 & 14 & 31.680943 & 39.463801 \\\\\n",
"15 & 15 & 10 & 12.939332 & 21.024440 \\\\\n",
"16 & 12 & 16 & 52.182387 & 20.134960 \\\\\n",
"17 & 17 & 12 & 11.829163 & 19.060309 \\\\\n",
"18 & 14 & 18 & 28.551572 & 5.099774 \\\\\n",
"19 & 19 & 14 & 12.255139 & 17.102630 \\\\\n",
"20 & 16 & 20 & 50.604803 & 14.958714 \\\\\n",
"21 & 21 & 16 & 13.888830 & 20.455154 \\\\\n",
"22 & 18 & 22 & 24.973227 & 31.428602 \\\\\n",
"23 & 23 & 18 & 13.729161 & 21.627703 \\\\\n",
"24 & 20 & 24 & 49.236951 & 7.909941 \\\\\n",
"25 & 25 & 20 & 12.734025 & 20.496765 \\\\\n",
"26 & 22 & 26 & 21.717889 & 46.729327 \\\\\n",
"27 & 27 & 22 & 13.839444 & 21.349888 \\\\\n",
"28 & 24 & 28 & 11.686263 & 31.679314 \\\\\n",
"29 & 29 & 24 & 18.180045 & 18.952334 \\\\\n",
"30 & 30 & 26 & 12.328640 & 48.499138 \\\\\n",
"31 & 31 & 26 & 36.644469 & 49.579788 \\\\\n",
"32 & 28 & 32 & 34.764891 & 10.017552 \\\\\n",
"33 & 33 & 28 & 32.885563 & 20.560408 \\\\\n",
"34 & 30 & 34 & 30.055622 & 14.284048 \\\\\n",
"35 & 35 & 30 & 12.228567 & 19.529234 \\\\\n",
"36 & 31 & 36 & 11.880768 & 32.334704 \\\\\n",
"37 & 37 & 31 & 32.542582 & 16.935521 \\\\\n",
"38 & 32 & 38 & 11.585311 & 73.412250 \\\\\n",
"39 & 39 & 32 & 27.435557 & 20.271400 \\\\\n",
"40 & 34 & 40 & 13.346154 & 32.862371 \\\\\n",
"41 & 41 & 34 & 13.452739 & 19.670021 \\\\\n",
"42 & 36 & 42 & 30.372801 & 13.061121 \\\\\n",
"43 & 43 & 36 & 12.230210 & 22.370202 \\\\\n",
"44 & 44 & 38 & 24.806375 & 20.561362 \\\\\n",
"45 & 40 & 45 & 12.273165 & 0.187530 \\\\\n",
"46 & 46 & 40 & 12.228567 & 21.000992 \\\\\n",
"47 & 42 & 47 & 27.727496 & 16.802088 \\\\\n",
"48 & 48 & 42 & 11.683860 & 22.149395 \\\\\n",
"49 & 45 & 49 & 21.881834 & 18.490914 \\\\\n",
"50 & 50 & 45 & 11.719795 & 19.349860 \\\\\n",
"51 & 47 & 51 & 25.142896 & 16.909912 \\\\\n",
"52 & 52 & 47 & 12.397299 & 16.801829 \\\\\n",
"53 & 49 & 53 & 17.023764 & 44.770455 \\\\\n",
"54 & 54 & 49 & 11.685101 & 17.629281 \\\\\n",
"55 & 51 & 55 & 22.257728 & 24.231841 \\\\\n",
"56 & 56 & 51 & 11.689688 & 21.619743 \\\\\n",
"57 & 53 & 57 & 11.995206 & 15.642695 \\\\\n",
"58 & 58 & 53 & 13.747949 & 19.635250 \\\\\n",
"59 & 55 & 59 & 16.451005 & 8.708682 \\\\\n",
"60 & 60 & 55 & 11.694390 & 21.449777 \\\\\n",
"61 & 57 & 61 & 12.079882 & 47.303283 \\\\\n",
"62 & 62 & 57 & 11.570908 & 20.904415 \\\\\n",
"63 & 63 & 59 & 14.992362 & 4.300275 \\\\\n",
"64 & 61 & 64 & 11.995206 & 18.471603 \\\\\n",
"65 & 65 & 61 & 11.694000 & 17.817003 \\\\\n",
"66 & 66 & 63 & 11.995206 & 21.400020 \\\\\n",
"67 & 67 & 64 & 11.570908 & 19.529438 \\\\\n",
"\\bottomrule\n",
"\\end{tabular}\n"
]
}
],
"source": [
"latex_code = edges_df.to_latex(index=False)\n",
"print(latex_code)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-07T14:29:30.575556900Z",
"start_time": "2024-03-07T14:29:29.834086300Z"
}
},
"id": "980e1ba9f4a748e4"
},
{
"cell_type": "code",
"execution_count": 134,
"outputs": [],
"source": [
"for idx, (u, v, data) in enumerate(sorted(network_graph.edges(data=True), key=lambda x: int(x[2]['solver_name']))):\n",
" network_graph[u][v]['mass_flow_rate_actual'] = m_solution[idx][0]"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-07T16:07:33.942409500Z",
"start_time": "2024-03-07T16:07:33.155887200Z"
}
},
"id": "d33ad2a2eb78fd0"
},
{
"cell_type": "code",
"execution_count": 198,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Temperatures at the final time step: [78.18664027 78.1865898 78.1853651 78.18432742 78.18383629 78.18319726\n",
" 78.18266043 78.18364069 78.18290756 78.18392728 78.18268013 78.18152717\n",
" 78.18037209 78.17937684 78.17865192 78.17816613 78.1775758 78.17671086\n",
" 78.17610327 78.17563732 78.1750894 78.1748886 78.17359073 78.17300582\n",
" 78.17118745 78.17058708 78.16995702 78.16851666 78.16752476 78.16741675\n",
" 78.16668729 80. 78.17469718 78.18097176 78.18417283 78.18730318\n",
" 78.17541928 78.18602646 78.18868036 78.18222945 78.18687169 78.18549436\n",
" 78.18745297 78.18331928 78.18201243 78.18078221 78.17804919 78.18177658\n",
" 78.17576141 78.17874528 78.17766322 78.17795258 78.17734928 78.17747959\n",
" 78.1741951 78.18008809 78.17616829 78.17995149 78.17727187 78.17215487\n",
" 78.17066253 78.17596763 78.18353447 78.17598846 78.18339893 78.17228927\n",
" 78.17720437]\n"
]
}
],
"source": [
"import numpy as np\n",
"import networkx as nx\n",
"\n",
"# Example Directed Graph Construction\n",
"# Replace this with your actual graph construction logic\n",
"di_graph = nx.DiGraph(network_graph)\n",
"\n",
"# Parameters\n",
"T_initial = 80 # Initial temperature in Celsius\n",
"Tg = 3 # Ground temperature in Celsius\n",
"cp = 4200 # Specific heat capacity of water in J/(kg*K)\n",
"rho = 980 # Density of water in kg/m3\n",
"dx = 20 # Number of segments for each pipe\n",
"delta_t = 60 # Time step in seconds\n",
"\n",
"n = di_graph.number_of_nodes() # Number of nodes\n",
"m = di_graph.number_of_edges() # Number of pipes\n",
"U = np.array([0.5 for _ in range(m)])\n",
"lengths_list = []\n",
"diameters_list = []\n",
"for u, v, data in di_graph.edges(data=True):\n",
" lengths_list.append(data['weight'])\n",
" diameters_list.append(data['diameter'])\n",
"\n",
"# Convert lists to numpy arrays\n",
"lengths = np.array(lengths_list)\n",
"diameters = np.array(diameters_list)\n",
"\n",
"# Calculate cross-sectional area (A) for each pipe\n",
"A = np.pi * (diameters ** 2) / 4\n",
"\n",
"delta_x = lengths / dx\n",
"\n",
"# Creating an array of mass flow rates 'G'\n",
"G = np.array([data['mass_flow_rate_actual'] for u, v, data in di_graph.edges(data=True)])\n",
"\n",
"\n",
"# Initialize temperature distribution along pipes\n",
"T_deltat = {edge: np.full((dx+1), T_initial) for edge in di_graph.edges()} # Temperature distribution along pipes\n",
"node_index_map = {node: idx for idx, node in enumerate(di_graph.nodes())}\n",
"\n",
"# Simulation parameters (adjust based on your setup)\n",
"steps = 50 # Number of time steps to simulate\n",
"\n",
"T_t = np.zeros(dx + 1)\n",
"T_input = np.full(n, T_initial)\n",
"T_output = np.zeros((steps, m))\n",
"T_final_outlet = np.zeros(n)\n",
"results = np.zeros((steps, n))\n",
"\n",
"# Main simulation loop\n",
"for i in range(steps):\n",
" for j, (u, v, data) in enumerate(di_graph.edges(data=True)):\n",
" # If the flow is negative, reverse the edge direction (this is conceptual; adjust based on your graph structure)\n",
" if data['mass_flow_rate_actual'] < 0:\n",
" di_graph.add_edge(v, u, **data)\n",
" di_graph.remove_edge(u, v)\n",
" mass_flow_rate = abs(data['mass_flow_rate_actual'])\n",
" else:\n",
" mass_flow_rate = data['mass_flow_rate_actual']\n",
"\n",
" C1 = 2 * delta_t * U[j] / (A[j] * rho * cp)\n",
" C2 = 2 * abs(mass_flow_rate) * delta_t / (rho * A[j] * delta_x[j])\n",
" C = 1 / (1 + C1 + C2)\n",
" # Inside your loop\n",
" T_t[0] = T_input[node_index_map[u]] # Use the mapped index to access the correct initial temperature\n",
"\n",
" for z in range(60): # Assuming additional iterations for convergence\n",
" for k in range(dx):\n",
" # Corrected to access T_deltat using edge (u, v) tuple\n",
" T_t[k+1] = C * (T_deltat[(u, v)][k+1] + C1 * Tg + C2 * T_t[k])\n",
"\n",
" # Corrected to store updated temperatures back in T_deltat using edge (u, v) tuple\n",
" T_deltat[(u, v)] = T_t\n",
" \n",
" # Corrected to store temperatures in T_output with edge index 'j'\n",
" T_output[i, j] = T_t[dx]\n",
" \n",
" for node in di_graph.nodes():\n",
" T_tot = 0.0\n",
" G_tot = 0.0\n",
" incoming_edges = di_graph.in_edges(node, data=True)\n",
" Count = len(incoming_edges)\n",
" \n",
" temp_incoming = []\n",
" flow_incoming = []\n",
" \n",
" for u, v, data in incoming_edges:\n",
" edge_index = list(di_graph.edges()).index((u, v))\n",
" temp_incoming.append(T_output[i, edge_index])\n",
" flow_incoming.append(abs(G[edge_index]))\n",
" \n",
" if Count > 1:\n",
" T_tot = np.dot(temp_incoming, flow_incoming)\n",
" G_tot = sum(flow_incoming)\n",
" T_final_outlet[node_index_map[node]] = T_tot / G_tot if G_tot else T_initial\n",
" elif Count == 1:\n",
" T_final_outlet[node_index_map[node]] = temp_incoming[0]\n",
" else:\n",
" T_final_outlet[node_index_map[node]] = T_initial\n",
" \n",
" # At the end of the step, adjust for source nodes and copy T_final_outlet to T_input\n",
" for node, data in di_graph.nodes(data=True):\n",
" if data.get('solver_name') == '1':\n",
" T_final_outlet[node_index_map[node]] = 80 # Reset source node temperature\n",
"\n",
" T_input = T_final_outlet.copy()\n",
" results[i, :] = T_final_outlet\n",
" \n",
"\n",
" \n",
"print(\"Temperatures at the final time step:\", results[-1, :])"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-08T11:19:49.631650300Z",
"start_time": "2024-03-08T11:19:31.847446800Z"
}
},
"id": "971b616575eeeae7"
},
{
"cell_type": "code",
"execution_count": 199,
"outputs": [
{
"data": {
"text/plain": " Time Step (293268.92232946283, 5040206.601044122) \\\n0 0 79.999991 \n1 1 79.984571 \n2 2 79.938864 \n3 3 79.893189 \n4 4 79.847931 \n5 5 79.806133 \n6 6 79.771978 \n7 7 79.741512 \n8 8 79.706654 \n9 9 79.666174 \n10 10 79.623977 \n11 11 79.584010 \n12 12 79.547721 \n13 13 79.513287 \n14 14 79.477642 \n15 15 79.439476 \n16 16 79.399958 \n17 17 79.361138 \n18 18 79.324050 \n19 19 79.288091 \n20 20 79.251873 \n21 21 79.214569 \n22 22 79.176483 \n23 23 79.138538 \n24 24 79.101367 \n25 25 79.064843 \n26 26 79.028360 \n27 27 78.991446 \n28 28 78.954128 \n29 29 78.916800 \n30 30 78.879808 \n31 31 78.843173 \n32 32 78.806643 \n33 33 78.769969 \n34 34 78.733109 \n35 35 78.696222 \n36 36 78.659484 \n37 37 78.622941 \n38 38 78.586497 \n39 39 78.550028 \n40 40 78.513490 \n41 41 78.476941 \n42 42 78.440465 \n43 43 78.404102 \n44 44 78.367817 \n45 45 78.331553 \n46 46 78.295278 \n47 47 78.259011 \n48 48 78.222790 \n49 49 78.186640 \n\n (293162.4584459267, 5040298.134698394) \\\n0 79.999999 \n1 79.984490 \n2 79.938783 \n3 79.893108 \n4 79.847855 \n5 79.806077 \n6 79.771946 \n7 79.741477 \n8 79.706599 \n9 79.666105 \n10 79.623909 \n11 79.583955 \n12 79.547676 \n13 79.513243 \n14 79.477590 \n15 79.439416 \n16 79.399898 \n17 79.361082 \n18 79.324000 \n19 79.288042 \n20 79.251821 \n21
"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>Time Step</th>\n <th>(293268.92232946283, 5040206.601044122)</th>\n <th>(293162.4584459267, 5040298.134698394)</th>\n <th>(293169.9422966335, 5040254.972466738)</th>\n <th>(293161.9162166267, 5040243.155704052)</th>\n <th>(293243.96496123145, 5040244.083651768)</th>\n <th>(293208.27353312843, 5040191.91032603)</th>\n <th>(293179.0032363437, 5040271.258029018)</th>\n <th>(293228.2223414392, 5040216.721843737)</th>\n <th>(293212.70831835904, 5040249.072585436)</th>\n <th>...</th>\n <th>(293168.8711824724, 5040218.090067068)</th>\n <th>(293254.3945879081, 5040221.622179406)</th>\n <th>(293181.600750976, 5040305.67762853)</th>\n <th>(293161.4860233397, 5040319.189840496)</th>\n <th>(293259.9504738339, 5040229.95785464)</th>\n <th>(293219.23492961464, 5040168.871007625)</th>\n <th>(293319.5070828843, 5040216.163684101)</th>\n <th>(293213.057996733, 5040284.545999)</th>\n <th>(293154.256991112, 5040324.04599453)</th>\n <th>(293271.554, 5040247.367)</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>0</td>\n <td>79.999991</td>\n <td>79.999999</td>\n <td>79.999990</td>\n <td>79.999992</td>\n <td>79.999999</td>\n <td>79.999990</td>\n <td>79.999990</td>\n <td>79.999990</td>\n <td>79.999990</td>\n <td>...</td>\n <td>79.999990</td>\n <td>79.999998</td>\n <td>79.999997</td>\n <td>79.999995</td>\n <td>79.999998</td>\n <td>79.999996</td>\n <td>80.000000</td>\n <td>79.999998</td>\n <td>79.999994</td>\n <td>80.000000</td>\n </tr>\n <tr>\n <th>1</th>\n <td>1</td>\n <td>79.984571</td>\n <td>79.984490</td>\n <td>79.983150</td>\n <td>79.982018</td>\n <td>79.981472</td>\n <td>79.980720</td>\n <td>79.980147</td>\n <td>79.978423</td>\n <td>79.977620</td>\n <td>...</td>\n <td>79.974141</td>\n <td>79.970902</td>\n <td>79.963269</td>\n <td>79.961862</td>\n <td>79.968989</td>\n <td>79.980098</td>\n <td>79.969750</td>\n <td>79.979534</td>\n <td>79.962874</td>\n <td>79.971599</td>\n </tr>\n <tr>\n <th>2</th>\n <td>2</td>\n <td>79.938864</td>\n <td>79.938783</td>\n <td>79.937444</td>\n <td>79.936312</td>\n <td>79.935766</td>\n <td>79.935016</td>\n <td>79.934443</td>\n <td>79.932720</td>\n <td>79.931917</td>\n <td>...</td>\n <td>79.928441</td>\n <td>79.925205</td>\n <td>79.917576</td>\n <td>79.916170</td>\n <td>79.923293</td>\n <td>79.934395</td>\n <td>79.924053</td>\n <td>79.933831</td>\n <td>79.917182</td>\n <td>79.925901</td>\n </tr>\n <tr>\n <th>3</th>\n <td>3</td>\n <td>79.893189</td>\n <td>79.893108</td>\n <td>79.891771</td>\n <td>79.890640</td>\n <td>79.890094</td>\n <td>79.889344</td>\n <td>79.888772</td>\n <td>79.887076</td>\n <td>79.886275</td>\n <td>...</td>\n <td>79.882880</td>\n <td>79.879673</td>\n <td>79.872113</td>\n <td>79.870716</td>\n <td>79.877773</td>\n <td>79.888767</td>\n <td>79.878528</td>\n <td>79.888207</td>\n <td>79.871723</td>\n <td>79.880343</td>\n </tr>\n <tr>\n <th>4</th>\n <td>4</td>\n <td>79.847931</td>\n <td>79.847855</td>\n <td>79.846530</td>\n <td>79.845410</td>\n <td>79.844871</td>\n <td>79.844136</td>\n <td>79.843567</td>\n <td>79.842472</td>\n <td>79.841687</td>\n <td>...</td>\n <td>79.838847</td>\n
},
"execution_count": 199,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"node_labels = [node for node in di_graph.nodes()]\n",
"\n",
"# Convert the results array to a pandas DataFrame\n",
"results_df = pd.DataFrame(results, columns=node_labels)\n",
"\n",
"# Optional: If you want to add a column or index that indicates the time step\n",
"results_df.index.name = 'Time Step'\n",
"results_df.reset_index(inplace=True)\n",
"\n",
"# Showing the DataFrame\n",
"results_df"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-08T11:20:03.482299200Z",
"start_time": "2024-03-08T11:20:02.899695700Z"
}
},
"id": "eb38aad026338932"
},
{
"cell_type": "code",
"execution_count": 200,
"outputs": [],
"source": [
"for node in di_graph.nodes():\n",
" if 'temperature_history' not in di_graph.nodes[node]:\n",
" di_graph.nodes[node]['temperature_history'] = []"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-08T11:24:19.494596600Z",
"start_time": "2024-03-08T11:24:18.463102Z"
}
},
"id": "ce01a2ebcf719a1f"
},
{
"cell_type": "code",
"execution_count": 201,
"outputs": [],
"source": [
"last_temperatures = results_df.iloc[-1]\n",
"\n",
"# Skipping the first column if it's \"Time Step\", or adjust according to your DataFrame structure\n",
"for node in di_graph.nodes():\n",
" # Ensure the node label matches the DataFrame's column for correct data appending\n",
" temperature = last_temperatures[node] if node in last_temperatures else None\n",
" if temperature is not None:\n",
" di_graph.nodes[node]['temperature_history'].append(temperature)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-08T11:24:33.186227700Z",
"start_time": "2024-03-08T11:24:32.711855200Z"
}
},
"id": "1a5fa74ffcc61119"
},
{
"cell_type": "code",
"execution_count": 208,
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"data": [
{
"hoverinfo": "none",
"line": {
"color": "#888",
"width": 0.5
},
"mode": "lines",
"x": [
293268.92232946283,
293251.93105040304,
null,
293162.4584459267,
293171.90206806763,
null,
293169.9422966335,
293186.20481946884,
null,
293161.9162166267,
293178.29597659543,
null,
293243.96496123145,
293253.3895766028,
null,
293208.27353312843,
293226.4958520454,
null,
293179.0032363437,
293196.49133223895,
null,
293228.2223414392,
293244.0825581944,
null,
293212.70831835904,
293196.59516456636,
null,
293201.0374294459,
293186.35704876215,
null,
293177.91918802116,
293161.56838219793,
null,
293168.61618659477,
293152.78058224276,
null,
293211.21706085204,
293198.74294034916,
null,
293249.93628141866,
293232.9154049299,
null,
293221.9359037339,
293209.58491002093,
null,
293247.62836591585,
293236.59445823065,
null,
293162.5326243373,
293150.67694876884,
null,
293274.85871539445,
293263.5810838301,
null,
293221.1012564584,
293230.2752063758,
null,
293258.2672356481,
293241.2117340568,
null,
293237.5724254025,
293225.9712000135,
null,
293221.0543914453,
293236.8247611614,
null,
293263.9478932525,
293252.495689268,
null,
293193.935307871,
293179.0986062601,
null,
293186.26851059805,
293195.6375827925,
null,
293185.13387576357,
293168.8711824724,
null,
293237.28612816025,
293254.3945879081,
null,
293193.65639875695,
293181.600750976,
null,
293173.44689440983,
293161.4860233397,
null,
293276.818447755,
293259.9504738339,
null,
293202.12567603646,
293219.23492961464,
null,
293328.35617741547,
293319.5070828843,
null,
293251.93105040304,
293271.554,
null,
293251.93105040304,
293226.4958520454,
null,
293251.93105040304,
293268.92232946283,
null,
293171.90206806763,
293162.4584459267,
null,
293171.90206806763,
293213.057996733,
null,
293171.90206806763,
293198.74294034916,
null,
293186.20481946884,
293178.29597659543,
null,
293186.20481946884,
293169.9422966335,
null,
293186.20481946884,
293213.057996733,
null,
293178.29597659543,
293186.20481946884,
null,
293178.29597659543,
293161.9162166267,
null,
293178.29597659543,
293196.49133223895,
null,
293253.3895766028,
293243.96496123145,
null,
293253.3895766028,
293271.554,
null,
293253.3895766028,
293236.59445823065,
null,
293226.4958520454,
293251.93105040304,
null,
293226.4958520454,
293244.0825581944,
null,
293226.4958520454,
293208.27353312843,
null,
293196.49133223895,
293179.0032363437,
null,
293196.49133223895,
293178.29597659543,
null,
293196.49133223895,
293196.59516456636,
null,
293244.0825581944,
293226.4958520454,
null,
293244.0825581944,
293232.9154049299,
null,
293244.0825581944,
293228.2223414392,
null,
293196.59516456636,
293186.35704876215,
null,
293196.59516456636,
293212.70831835904,
null,
293196.59516456636,
293196.49133223895,
null,
293186.35704876215,
293196.59516456636,
null,
293186.35704876215,
293161.56838219793,
null,
293186.35704876215,
293201.0374294459,
null,
293161.56838219793,
293186.35704876215,
null,
293161.56838219793,
293152.78058224276,
null,
293161.56838219793,
293177.91918802116,
null,
293152.78058224276,
293161.56838219793,
null,
293152.78058224276,
293168.61618659477,
null,
293152.78058224276,
293179.0986062601,
null,
293198.74294034916,
293209.58491002093,
null,
293198.74294034916,
293211.21706085204,
null,
293198.74294034916,
293171.90206806763,
null,
293232.9154049299,
293244.0825581944,
null,
293232.9154049299,
293241.2117340568,
null,
293232.9154049299,
293249.93628141866,
null,
293209.58491002093,
293198.74294034916,
null,
293209.58491002093,
293195.6375827925,
null,
293209.58491002093,
293221.9359037339,
null,
293236.59445823065,
293263.5810838301,
null,
293236.59445823065,
293247.62836591585,
null,
293236.59445823065,
293253.3895766028,
null,
293150.67694876884,
293162.5326243373,
null,
293150.67694876884,
293154.256991112,
null,
293263.5810838301,
293236.59445823065,
null,
293263.5810838301,
293230.2752063758,
null,
293263.5810838301,
293274.85871539445,
null,
293230.2752063758,
293263.5810838301,
null,
293230.2752063758,
293225.9712000135,
null,
293230.2752063758,
293221.1012564584,
null,
293241.2117340568,
293232.9154049299,
null,
293241.2117340568,
293236.8247611614,
null,
293241.2117340568,
293258.2672356481,
null,
293225.9712000135,
293230.2752063758,
null,
293225.9712000135,
293252.495689268,
null,
293225.9712000135,
293237.5724254025,
null,
293236.8247611614,
293241.2117340568,
null,
293236.8247611614,
293221.0543914453,
null,
293236.8247611614,
293254.3945879081,
null,
293252.495689268,
293225.9712000135,
null,
293252.495689268,
293213.057996733,
null,
293252.495689268,
293263.9478932525,
null,
293179.0986062601,
293193.935307871,
null,
293179.0986062601,
293152.78058224276,
null,
293179.0986062601,
293168.8711824724,
null,
293195.6375827925,
293209.58491002093,
null,
293195.6375827925,
293181.600750976,
null,
293195.6375827925,
293186.26851059805,
null,
293168.8711824724,
293185.13387576357,
null,
293168.8711824724,
293179.0986062601,
null,
293254.3945879081,
293259.9504738339,
null,
293254.3945879081,
293237.28612816025,
null,
293254.3945879081,
293236.8247611614,
null,
293181.600750976,
293195.6375827925,
null,
293181.600750976,
293161.4860233397,
null,
293181.600750976,
293193.65639875695,
null,
293161.4860233397,
293181.600750976,
null,
293161.4860233397,
293154.256991112,
null,
293161.4860233397,
293173.44689440983,
null,
293259.9504738339,
293254.3945879081,
null,
293259.9504738339,
293276.818447755,
null,
293259.9504738339,
293219.23492961464,
null,
293219.23492961464,
293202.12567603646,
null,
293219.23492961464,
293259.9504738339,
null,
293319.5070828843,
293271.554,
null,
293319.5070828843,
293328.35617741547,
null,
293213.057996733,
293252.495689268,
null,
293213.057996733,
293171.90206806763,
null,
293213.057996733,
293186.20481946884,
null,
293154.256991112,
293161.4860233397,
null,
293154.256991112,
293150.67694876884,
null,
293271.554,
293251.93105040304,
null,
293271.554,
293319.5070828843,
null,
293271.554,
293253.3895766028,
null
],
"y": [
5040206.601044122,
5040217.926054459,
null,
5040298.134698394,
5040312.19278805,
null,
5040254.972466738,
5040244.159450427,
null,
5040243.155704052,
5040232.264736303,
null,
5040244.083651768,
5040258.911978145,
null,
5040191.91032603,
5040179.7648042375,
null,
5040271.258029018,
5040259.63012429,
null,
5040216.721843737,
5040206.150707917,
null,
5040249.072585436,
5040259.786285674,
null,
5040234.62735603,
5040244.388399713,
null,
5040196.235110773,
5040207.106826794,
null,
5040180.519320131,
5040194.16586493,
null,
5040312.731630573,
5040294.162240376,
null,
5040178.0515293395,
5040189.396266925,
null,
5040305.265169374,
5040286.879069806,
null,
5040286.946975689,
5040269.586650846,
null,
5040344.244190009,
5040326.42836015,
null,
5040270.178231545,
5040252.434440949,
null,
5040259.169113723,
5040273.603052741,
null,
5040190.475701797,
5040201.843517671,
null,
5040294.591521784,
5040276.338601143,
null,
5040205.772851501,
5040195.261600439,
null,
5040277.498572837,
5040259.480116727,
null,
5040223.606890397,
5040233.471872488,
null,
5040282.301174366,
5040296.248286495,
null,
5040207.2769374205,
5040218.090067068,
null,
5040233.025292898,
5040221.622179406,
null,
5040323.624066331,
5040305.67762853,
null,
5040336.995190537,
5040319.189840496,
null,
5040218.71502952,
5040229.95785464,
null,
5040180.27465022,
5040168.871007625,
null,
5040229.762923518,
5040216.163684101,
null,
5040217.926054459,
5040247.367,
null,
5040217.926054459,
5040179.7648042375,
null,
5040217.926054459,
5040206.601044122,
null,
5040312.19278805,
5040298.134698394,
null,
5040312.19278805,
5040284.545999,
null,
5040312.19278805,
5040294.162240376,
null,
5040244.159450427,
5040232.264736303,
null,
5040244.159450427,
5040254.972466738,
null,
5040244.159450427,
5040284.545999,
null,
5040232.264736303,
5040244.159450427,
null,
5040232.264736303,
5040243.155704052,
null,
5040232.264736303,
5040259.63012429,
null,
5040258.911978145,
5040244.083651768,
null,
5040258.911978145,
5040247.367,
null,
5040258.911978145,
5040269.586650846,
null,
5040179.7648042375,
5040217.926054459,
null,
5040179.7648042375,
5040206.150707917,
null,
5040179.7648042375,
5040191.91032603,
null,
5040259.63012429,
5040271.258029018,
null,
5040259.63012429,
5040232.264736303,
null,
5040259.63012429,
5040259.786285674,
null,
5040206.150707917,
5040179.7648042375,
null,
5040206.150707917,
5040189.396266925,
null,
5040206.150707917,
5040216.721843737,
null,
5040259.786285674,
5040244.388399713,
null,
5040259.786285674,
5040249.072585436,
null,
5040259.786285674,
5040259.63012429,
null,
5040244.388399713,
5040259.786285674,
null,
5040244.388399713,
5040207.106826794,
null,
5040244.388399713,
5040234.62735603,
null,
5040207.106826794,
5040244.388399713,
null,
5040207.106826794,
5040194.16586493,
null,
5040207.106826794,
5040196.235110773,
null,
5040194.16586493,
5040207.106826794,
null,
5040194.16586493,
5040180.519320131,
null,
5040194.16586493,
5040233.471872488,
null,
5040294.162240376,
5040286.879069806,
null,
5040294.162240376,
5040312.731630573,
null,
5040294.162240376,
5040312.19278805,
null,
5040189.396266925,
5040206.150707917,
null,
5040189.396266925,
5040201.843517671,
null,
5040189.396266925,
5040178.0515293395,
null,
5040286.879069806,
5040294.162240376,
null,
5040286.879069806,
5040296.248286495,
null,
5040286.879069806,
5040305.265169374,
null,
5040269.586650846,
5040252.434440949,
null,
5040269.586650846,
5040286.946975689,
null,
5040269.586650846,
5040258.911978145,
null,
5040326.42836015,
5040344.244190009,
null,
5040326.42836015,
5040324.04599453,
null,
5040252.434440949,
5040269.586650846,
null,
5040252.434440949,
5040273.603052741,
null,
5040252.434440949,
5040270.178231545,
null,
5040273.603052741,
5040252.434440949,
null,
5040273.603052741,
5040276.338601143,
null,
5040273.603052741,
5040259.169113723,
null,
5040201.843517671,
5040189.396266925,
null,
5040201.843517671,
5040195.261600439,
null,
5040201.843517671,
5040190.475701797,
null,
5040276.338601143,
5040273.603052741,
null,
5040276.338601143,
5040259.480116727,
null,
5040276.338601143,
5040294.591521784,
null,
5040195.261600439,
5040201.843517671,
null,
5040195.261600439,
5040205.772851501,
null,
5040195.261600439,
5040221.622179406,
null,
5040259.480116727,
5040276.338601143,
null,
5040259.480116727,
5040284.545999,
null,
5040259.480116727,
5040277.498572837,
null,
5040233.471872488,
5040223.606890397,
null,
5040233.471872488,
5040194.16586493,
null,
5040233.471872488,
5040218.090067068,
null,
5040296.248286495,
5040286.879069806,
null,
5040296.248286495,
5040305.67762853,
null,
5040296.248286495,
5040282.301174366,
null,
5040218.090067068,
5040207.2769374205,
null,
5040218.090067068,
5040233.471872488,
null,
5040221.622179406,
5040229.95785464,
null,
5040221.622179406,
5040233.025292898,
null,
5040221.622179406,
5040195.261600439,
null,
5040305.67762853,
5040296.248286495,
null,
5040305.67762853,
5040319.189840496,
null,
5040305.67762853,
5040323.624066331,
null,
5040319.189840496,
5040305.67762853,
null,
5040319.189840496,
5040324.04599453,
null,
5040319.189840496,
5040336.995190537,
null,
5040229.95785464,
5040221.622179406,
null,
5040229.95785464,
5040218.71502952,
null,
5040229.95785464,
5040168.871007625,
null,
5040168.871007625,
5040180.27465022,
null,
5040168.871007625,
5040229.95785464,
null,
5040216.163684101,
5040247.367,
null,
5040216.163684101,
5040229.762923518,
null,
5040284.545999,
5040259.480116727,
null,
5040284.545999,
5040312.19278805,
null,
5040284.545999,
5040244.159450427,
null,
5040324.04599453,
5040319.189840496,
null,
5040324.04599453,
5040326.42836015,
null,
5040247.367,
5040217.926054459,
null,
5040247.367,
5040216.163684101,
null,
5040247.367,
5040258.911978145,
null
],
"type": "scatter"
},
{
"hoverinfo": "text",
"marker": {
"color": [
78.18664026932207,
78.18658979717809,
78.18536509720988,
78.1843274150433,
78.1838362871793,
78.18319726041068,
78.18266042662819,
78.18364068824314,
78.18290755938142,
78.18392728157195,
78.18268012777467,
78.18152717394427,
78.18037209408065,
78.17937684381415,
78.17865191572604,
78.1781661297445,
78.17757580155065,
78.17671086015292,
78.17610326509721,
78.17563732439106,
78.17508939683864,
78.17488860454799,
78.17359073373323,
78.17300582123043,
78.17118745326324,
78.17058707680768,
78.16995702332291,
78.16851665909246,
78.16752476279436,
78.16741674528069,
78.16668729341728,
80.0,
78.17469718469721,
78.18097175915995,
78.18417282679407,
78.18730318264637,
78.17541928245123,
78.1860264607316,
78.18868036132965,
78.18222944847417,
78.1868716934778,
78.18549436200335,
78.18745297424097,
78.18331928160747,
78.18201243345831,
78.18078221322511,
78.17804918653522,
78.18177658366061,
78.17576140623375,
78.17874528236788,
78.17766322018711,
78.17795257834484,
78.1773492840138,
78.17747959271962,
78.1741950959567,
78.18008808825664,
78.17616828944418,
78.17995149429179,
78.17727187189143,
78.17215486689207,
78.17066253150507,
78.17596762805601,
78.18353447242453,
78.17598845871568,
78.18339893152177,
78.17228927354549,
78.17720437015865
],
"colorbar": {
"thickness": 15,
"title": {
"side": "right",
"text": "Node Temperature"
},
"xanchor": "left"
},
"colorscale": [
[
0.0,
"rgb(255,255,217)"
],
[
0.125,
"rgb(237,248,177)"
],
[
0.25,
"rgb(199,233,180)"
],
[
0.375,
"rgb(127,205,187)"
],
[
0.5,
"rgb(65,182,196)"
],
[
0.625,
"rgb(29,145,192)"
],
[
0.75,
"rgb(34,94,168)"
],
[
0.875,
"rgb(37,52,148)"
],
[
1.0,
"rgb(8,29,88)"
]
],
"showscale": true,
"size": 10
},
"mode": "markers",
"text": [
"Temperature: [78.18664026932207]<br>Peak Demand: [22841.995042321723]",
"Temperature: [78.18658979717809]<br>Peak Demand: [21967.361349490955]",
"Temperature: [78.18536509720988]<br>Peak Demand: [16553.163397948596]",
"Temperature: [78.1843274150433]<br>Peak Demand: [18447.32612999839]",
"Temperature: [78.1838362871793]<br>Peak Demand: [18731.285969369717]",
"Temperature: [78.18319726041068]<br>Peak Demand: [20648.53842761628]",
"Temperature: [78.18266042662819]<br>Peak Demand: [16835.974529342628]",
"Temperature: [78.18364068824314]<br>Peak Demand: [18522.605026568282]",
"Temperature: [78.18290755938142]<br>Peak Demand: [18954.825167108527]",
"Temperature: [78.18392728157195]<br>Peak Demand: [16852.775626372248]",
"Temperature: [78.18268012777467]<br>Peak Demand: [16866.33530265568]",
"Temperature: [78.18152717394427]<br>Peak Demand: [27720.79594997572]",
"Temperature: [78.18037209408065]<br>Peak Demand: [18577.135108146904]",
"Temperature: [78.17937684381415]<br>Peak Demand: [23246.287058843147]",
"Temperature: [78.17865191572604]<br>Peak Demand: [16939.696450208918]",
"Temperature: [78.1781661297445]<br>Peak Demand: [17293.074545317442]",
"Temperature: [78.17757580155065]<br>Peak Demand: [17745.20518409542]",
"Temperature: [78.17671086015292]<br>Peak Demand: [17257.331795860133]",
"Temperature: [78.17610326509721]<br>Peak Demand: [23790.135607014832]",
"Temperature: [78.17563732439106]<br>Peak Demand: [23621.25090594008]",
"Temperature: [78.17508939683864]<br>Peak Demand: [19998.481038768598]",
"Temperature: [78.17488860454799]<br>Peak Demand: [18745.45363768308]",
"Temperature: [78.17359073373323]<br>Peak Demand: [16842.90054794746]",
"Temperature: [78.17300582123043]<br>Peak Demand: [16865.211967454747]",
"Temperature: [78.17118745326324]<br>Peak Demand: [16839.550818732256]",
"Temperature: [78.17058707680768]<br>Peak Demand: [16512.029713406835]",
"Temperature: [78.16995702332291]<br>Peak Demand: [17408.230276348935]",
"Temperature: [78.16851665909246]<br>Peak Demand: [23309.955779841228]",
"Temperature: [78.16752476279436]<br>Peak Demand: [17996.62291500036]",
"Temperature: [78.16741674528069]<br>Peak Demand: [22319.632352352917]",
"Temperature: [78.16668729341728]<br>Peak Demand: [18442.36993407752]",
"Temperature: [80.0]<br>Peak Demand: N/A",
"Temperature: [78.17469718469721]<br>Peak Demand: N/A",
"Temperature: [78.18097175915995]<br>Peak Demand: N/A",
"Temperature: [78.18417282679407]<br>Peak Demand: N/A",
"Temperature: [78.18730318264637]<br>Peak Demand: N/A",
"Temperature: [78.17541928245123]<br>Peak Demand: N/A",
"Temperature: [78.1860264607316]<br>Peak Demand: N/A",
"Temperature: [78.18868036132965]<br>Peak Demand: N/A",
"Temperature: [78.18222944847417]<br>Peak Demand: N/A",
"Temperature: [78.1868716934778]<br>Peak Demand: N/A",
"Temperature: [78.18549436200335]<br>Peak Demand: N/A",
"Temperature: [78.18745297424097]<br>Peak Demand: N/A",
"Temperature: [78.18331928160747]<br>Peak Demand: N/A",
"Temperature: [78.18201243345831]<br>Peak Demand: N/A",
"Temperature: [78.18078221322511]<br>Peak Demand: N/A",
"Temperature: [78.17804918653522]<br>Peak Demand: N/A",
"Temperature: [78.18177658366061]<br>Peak Demand: N/A",
"Temperature: [78.17576140623375]<br>Peak Demand: N/A",
"Temperature: [78.17874528236788]<br>Peak Demand: N/A",
"Temperature: [78.17766322018711]<br>Peak Demand: N/A",
"Temperature: [78.17795257834484]<br>Peak Demand: N/A",
"Temperature: [78.1773492840138]<br>Peak Demand: N/A",
"Temperature: [78.17747959271962]<br>Peak Demand: N/A",
"Temperature: [78.1741950959567]<br>Peak Demand: N/A",
"Temperature: [78.18008808825664]<br>Peak Demand: N/A",
"Temperature: [78.17616828944418]<br>Peak Demand: N/A",
"Temperature: [78.17995149429179]<br>Peak Demand: N/A",
"Temperature: [78.17727187189143]<br>Peak Demand: N/A",
"Temperature: [78.17215486689207]<br>Peak Demand: N/A",
"Temperature: [78.17066253150507]<br>Peak Demand: N/A",
"Temperature: [78.17596762805601]<br>Peak Demand: N/A",
"Temperature: [78.18353447242453]<br>Peak Demand: N/A",
"Temperature: [78.17598845871568]<br>Peak Demand: N/A",
"Temperature: [78.18339893152177]<br>Peak Demand: N/A",
"Temperature: [78.17228927354549]<br>Peak Demand: N/A",
"Temperature: [78.17720437015865]<br>Peak Demand: N/A"
],
"x": [
293268.92232946283,
293162.4584459267,
293169.9422966335,
293161.9162166267,
293243.96496123145,
293208.27353312843,
293179.0032363437,
293228.2223414392,
293212.70831835904,
293201.0374294459,
293177.91918802116,
293168.61618659477,
293211.21706085204,
293249.93628141866,
293221.9359037339,
293247.62836591585,
293162.5326243373,
293274.85871539445,
293221.1012564584,
293258.2672356481,
293237.5724254025,
293221.0543914453,
293263.9478932525,
293193.935307871,
293186.26851059805,
293185.13387576357,
293237.28612816025,
293193.65639875695,
293173.44689440983,
293276.818447755,
293202.12567603646,
293328.35617741547,
293251.93105040304,
293171.90206806763,
293186.20481946884,
293178.29597659543,
293253.3895766028,
293226.4958520454,
293196.49133223895,
293244.0825581944,
293196.59516456636,
293186.35704876215,
293161.56838219793,
293152.78058224276,
293198.74294034916,
293232.9154049299,
293209.58491002093,
293236.59445823065,
293150.67694876884,
293263.5810838301,
293230.2752063758,
293241.2117340568,
293225.9712000135,
293236.8247611614,
293252.495689268,
293179.0986062601,
293195.6375827925,
293168.8711824724,
293254.3945879081,
293181.600750976,
293161.4860233397,
293259.9504738339,
293219.23492961464,
293319.5070828843,
293213.057996733,
293154.256991112,
293271.554
],
"y": [
5040206.601044122,
5040298.134698394,
5040254.972466738,
5040243.155704052,
5040244.083651768,
5040191.91032603,
5040271.258029018,
5040216.721843737,
5040249.072585436,
5040234.62735603,
5040196.235110773,
5040180.519320131,
5040312.731630573,
5040178.0515293395,
5040305.265169374,
5040286.946975689,
5040344.244190009,
5040270.178231545,
5040259.169113723,
5040190.475701797,
5040294.591521784,
5040205.772851501,
5040277.498572837,
5040223.606890397,
5040282.301174366,
5040207.2769374205,
5040233.025292898,
5040323.624066331,
5040336.995190537,
5040218.71502952,
5040180.27465022,
5040229.762923518,
5040217.926054459,
5040312.19278805,
5040244.159450427,
5040232.264736303,
5040258.911978145,
5040179.7648042375,
5040259.63012429,
5040206.150707917,
5040259.786285674,
5040244.388399713,
5040207.106826794,
5040194.16586493,
5040294.162240376,
5040189.396266925,
5040286.879069806,
5040269.586650846,
5040326.42836015,
5040252.434440949,
5040273.603052741,
5040201.843517671,
5040276.338601143,
5040195.261600439,
5040259.480116727,
5040233.471872488,
5040296.248286495,
5040218.090067068,
5040221.622179406,
5040305.67762853,
5040319.189840496,
5040229.95785464,
5040168.871007625,
5040216.163684101,
5040284.545999,
5040324.04599453,
5040247.367
],
"type": "scatter"
}
],
"layout": {
"hovermode": "closest",
"margin": {
"b": 20,
"l": 5,
"r": 5,
"t": 40
},
"showlegend": false,
"title": {
"font": {
"size": 16
},
"text": "<br>Network flow visualization"
},
"xaxis": {
"showgrid": false,
"showticklabels": false,
"zeroline": false
},
"yaxis": {
"showgrid": false,
"showticklabels": false,
"zeroline": false
},
"template": {
"data": {
"histogram2dcontour": [
{
"type": "histogram2dcontour",
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
]
}
],
"choropleth": [
{
"type": "choropleth",
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
}
],
"histogram2d": [
{
"type": "histogram2d",
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
]
}
],
"heatmap": [
{
"type": "heatmap",
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
]
}
],
"heatmapgl": [
{
"type": "heatmapgl",
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
]
}
],
"contourcarpet": [
{
"type": "contourcarpet",
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
}
],
"contour": [
{
"type": "contour",
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
]
}
],
"surface": [
{
"type": "surface",
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
]
}
],
"mesh3d": [
{
"type": "mesh3d",
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
}
],
"scatter": [
{
"fillpattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
},
"type": "scatter"
}
],
"parcoords": [
{
"type": "parcoords",
"line": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
}
}
],
"scatterpolargl": [
{
"type": "scatterpolargl",
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
}
}
],
"bar": [
{
"error_x": {
"color": "#2a3f5f"
},
"error_y": {
"color": "#2a3f5f"
},
"marker": {
"line": {
"color": "#E5ECF6",
"width": 0.5
},
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "bar"
}
],
"scattergeo": [
{
"type": "scattergeo",
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
}
}
],
"scatterpolar": [
{
"type": "scatterpolar",
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
}
}
],
"histogram": [
{
"marker": {
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "histogram"
}
],
"scattergl": [
{
"type": "scattergl",
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
}
}
],
"scatter3d": [
{
"type": "scatter3d",
"line": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
}
}
],
"scattermapbox": [
{
"type": "scattermapbox",
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
}
}
],
"scatterternary": [
{
"type": "scatterternary",
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
}
}
],
"scattercarpet": [
{
"type": "scattercarpet",
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
}
}
],
"carpet": [
{
"aaxis": {
"endlinecolor": "#2a3f5f",
"gridcolor": "white",
"linecolor": "white",
"minorgridcolor": "white",
"startlinecolor": "#2a3f5f"
},
"baxis": {
"endlinecolor": "#2a3f5f",
"gridcolor": "white",
"linecolor": "white",
"minorgridcolor": "white",
"startlinecolor": "#2a3f5f"
},
"type": "carpet"
}
],
"table": [
{
"cells": {
"fill": {
"color": "#EBF0F8"
},
"line": {
"color": "white"
}
},
"header": {
"fill": {
"color": "#C8D4E3"
},
"line": {
"color": "white"
}
},
"type": "table"
}
],
"barpolar": [
{
"marker": {
"line": {
"color": "#E5ECF6",
"width": 0.5
},
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "barpolar"
}
],
"pie": [
{
"automargin": true,
"type": "pie"
}
]
},
"layout": {
"autotypenumbers": "strict",
"colorway": [
"#636efa",
"#EF553B",
"#00cc96",
"#ab63fa",
"#FFA15A",
"#19d3f3",
"#FF6692",
"#B6E880",
"#FF97FF",
"#FECB52"
],
"font": {
"color": "#2a3f5f"
},
"hovermode": "closest",
"hoverlabel": {
"align": "left"
},
"paper_bgcolor": "white",
"plot_bgcolor": "#E5ECF6",
"polar": {
"bgcolor": "#E5ECF6",
"angularaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"radialaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
}
},
"ternary": {
"bgcolor": "#E5ECF6",
"aaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"baxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"caxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
}
},
"coloraxis": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"colorscale": {
"sequential": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"sequentialminus": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"diverging": [
[
0,
"#8e0152"
],
[
0.1,
"#c51b7d"
],
[
0.2,
"#de77ae"
],
[
0.3,
"#f1b6da"
],
[
0.4,
"#fde0ef"
],
[
0.5,
"#f7f7f7"
],
[
0.6,
"#e6f5d0"
],
[
0.7,
"#b8e186"
],
[
0.8,
"#7fbc41"
],
[
0.9,
"#4d9221"
],
[
1,
"#276419"
]
]
},
"xaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": "",
"title": {
"standoff": 15
},
"zerolinecolor": "white",
"automargin": true,
"zerolinewidth": 2
},
"yaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": "",
"title": {
"standoff": 15
},
"zerolinecolor": "white",
"automargin": true,
"zerolinewidth": 2
},
"scene": {
"xaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white",
"gridwidth": 2
},
"yaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white",
"gridwidth": 2
},
"zaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white",
"gridwidth": 2
}
},
"shapedefaults": {
"line": {
"color": "#2a3f5f"
}
},
"annotationdefaults": {
"arrowcolor": "#2a3f5f",
"arrowhead": 0,
"arrowwidth": 1
},
"geo": {
"bgcolor": "white",
"landcolor": "#E5ECF6",
"subunitcolor": "white",
"showland": true,
"showlakes": true,
"lakecolor": "white"
},
"title": {
"x": 0.05
},
"mapbox": {
"style": "light"
}
}
}
},
"config": {
"plotlyServerURL": "https://plot.ly"
}
},
"text/html": "<div> <div id=\"2be4ba45-cda8-44c2-8272-772cebc372e3\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div> <script type=\"text/javascript\"> require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {}; if (document.getElementById(\"2be4ba45-cda8-44c2-8272-772cebc372e3\")) { Plotly.newPlot( \"2be4ba45-cda8-44c2-8272-772cebc372e3\", [{\"hoverinfo\":\"none\",\"line\":{\"color\":\"#888\",\"width\":0.5},\"mode\":\"lines\",\"x\":[293268.92232946283,293251.93105040304,null,293162.4584459267,293171.90206806763,null,293169.9422966335,293186.20481946884,null,293161.9162166267,293178.29597659543,null,293243.96496123145,293253.3895766028,null,293208.27353312843,293226.4958520454,null,293179.0032363437,293196.49133223895,null,293228.2223414392,293244.0825581944,null,293212.70831835904,293196.59516456636,null,293201.0374294459,293186.35704876215,null,293177.91918802116,293161.56838219793,null,293168.61618659477,293152.78058224276,null,293211.21706085204,293198.74294034916,null,293249.93628141866,293232.9154049299,null,293221.9359037339,293209.58491002093,null,293247.62836591585,293236.59445823065,null,293162.5326243373,293150.67694876884,null,293274.85871539445,293263.5810838301,null,293221.1012564584,293230.2752063758,null,293258.2672356481,293241.2117340568,null,293237.5724254025,293225.9712000135,null,293221.0543914453,293236.8247611614,null,293263.9478932525,293252.495689268,null,293193.935307871,293179.0986062601,null,293186.26851059805,293195.6375827925,null,293185.13387576357,293168.8711824724,null,293237.28612816025,293254.3945879081,null,293193.65639875695,293181.600750976,null,293173.44689440983,293161.4860233397,null,293276.818447755,293259.9504738339,null,293202.12567603646,293219.23492961464,null,293328.35617741547,293319.5070828843,null,293251.93105040304,293271.554,null,293251.93105040304,293226.4958520454,null,293251.93105040304,293268.92232946283,null,293171.90206806763,293162.4584459267,null,293171.90206806763,293213.057996733,null,293171.90206806763,293198.74294034916,null,293186.20481946884,293178.29597659543,null,293186.20481946884,293169.9422966335,null,293186.20481946884,293213.057996733,null,293178.29597659543,293186.20481946884,null,293178.29597659543,293161.9162166267,null,293178.29597659543,293196.49133223895,null,293253.3895766028,293243.96496123145,null,293253.3895766028,293271.554,null,293253.3895766028,293236.59445823065,null,293226.4958520454,293251.93105040304,null,293226.4958520454,293244.0825581944,null,293226.4958520454,293208.27353312843,null,293196.49133223895,293179.0032363437,null,293196.49133223895,293178.29597659543,null,293196.49133223895,293196.59516456636,null,293244.0825581944,293226.4958520454,null,293244.0825581944,293232.9154049299,null,293244.0825581944,293228.2223414392,null,293196.59516456636,293186.35704876215,null,293196.59516456636,293212.70831835904,null,293196.59516456636,293196.49133223895,null,293186.35704876215,293196.59516456636,null,293186.35704876215,293161.56838219793,null,293186.35704876215,293201.0374294459,null,293161.56838219793,293186.35704876215,null,293161.56838219793,293152.78058224276,null,293161.56838219793,293177.91918802116,null,293152.78058224276,293161.56838219793,null,293152.78058224276,293168.61618659477,null,293152.78058224276,293179.0986062601,null,293198.74294034916,293209.58491002093,null,293198.74294034916,293211.21706085204,null,293198.74294034916,293171.90206806763,null,293232.9154049299,293244.0825581944,null,293232.9154049299,293241.2117340568,null,293232.9154049299,293249.93628141866,null,293209.58491002093,293198.74294034916,null,293209.58491002093,293195.6375827925,null,293209.58491002093,293221.9359037339,null,293236.59445823065,293263.5810838301,null,293236.59445823065,293247.62836591585,null,293236.59445823065,293253.3895766028,null,293150.67694876884,293162.5326243373,null,293150.67694876884,293154.256991112,null
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import plotly.graph_objects as go\n",
"\n",
"edge_x = []\n",
"edge_y = []\n",
"for edge in di_graph.edges():\n",
" x0, y0 = pos[edge[0]]\n",
" x1, y1 = pos[edge[1]]\n",
" edge_x.append(x0)\n",
" edge_x.append(x1)\n",
" edge_x.append(None) # Prevents drawing a line to the next edge\n",
" edge_y.append(y0)\n",
" edge_y.append(y1)\n",
" edge_y.append(None)\n",
"\n",
"edge_trace = go.Scatter(x=edge_x, y=edge_y, line=dict(width=0.5, color='#888'), hoverinfo='none', mode='lines')\n",
"\n",
"node_x = []\n",
"node_y = []\n",
"for node in di_graph.nodes():\n",
" x, y = pos[node]\n",
" node_x.append(x)\n",
" node_y.append(y)\n",
"\n",
"node_trace = go.Scatter(x=node_x, y=node_y, mode='markers', hoverinfo='text', marker=dict(showscale=True, colorscale='YlGnBu', color=[], size=10, colorbar=dict(thickness=15, title='Mass Flow Rate', xanchor='left', titleside='right')))\n",
"\n",
"# Initialize an empty list for colors\n",
"colors = []\n",
"\n",
"node_text = []\n",
"for node, data in di_graph.nodes(data=True):\n",
" node_info = f\"Temperature: {data.get('temperature_history', 'N/A')}<br>Peak Demand: {data.get('Peack_Demand', 'N/A')}\"\n",
" last_temp = data.get('temperature_history', [T_initial])[-1] if 'temperature_history' in data else T_initial\n",
" colors.append(last_temp) # Append the last known temperature to the colors list\n",
" node_text.append(node_info)\n",
"\n",
"# Make sure to set node_trace.marker.color using the colors list\n",
"node_trace = go.Scatter(\n",
" x=node_x, \n",
" y=node_y, \n",
" mode='markers',\n",
" hoverinfo='text',\n",
" marker=dict(\n",
" showscale=True,\n",
" # Use the colors list for node colors\n",
" color=colors, \n",
" size=10,\n",
" colorbar=dict(thickness=15, title='Node Temperature', xanchor='left', titleside='right'),\n",
" colorscale='YlGnBu'\n",
" ),\n",
" text=node_text\n",
")\n",
"\n",
"fig = go.Figure(data=[edge_trace, node_trace], layout=go.Layout(title='<br>Network flow visualization', titlefont_size=16, showlegend=False, hovermode='closest', margin=dict(b=20, l=5, r=5, t=40), xaxis=dict(showgrid=False, zeroline=False, showticklabels=False), yaxis=dict(showgrid=False, zeroline=False, showticklabels=False)))\n",
"\n",
"fig.show()\n"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-08T11:38:25.454409200Z",
"start_time": "2024-03-08T11:38:25.076630Z"
}
},
"id": "8aa3a462ab1e885"
},
{
"cell_type": "code",
"execution_count": 220,
"outputs": [],
"source": [
"from pyproj import Transformer\n",
"\n",
"# Initialize a transformer to convert from your current CRS to EPSG:4326\n",
"# Replace 'EPSG:XXXX' with your current coordinate system\n",
"transformer = Transformer.from_crs(\"EPSG:32188\", \"EPSG:4326\", always_xy=True)\n",
"\n",
"def convert_coordinates(geom):\n",
" return transformer.transform(geom.x, geom.y)\n",
"\n",
"for node in di_graph.nodes():\n",
" # node here is a tuple representing coordinates (x, y)\n",
" x, y = node # Unpack the tuple\n",
" lon, lat = transformer.transform(x, y) # Convert to geographic coordinates\n",
" \n",
" # Update the node's data with 'lat' and 'lon'\n",
" di_graph.nodes[node]['lat'] = lat\n",
" di_graph.nodes[node]['lon'] = lon"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-08T12:03:59.410046400Z",
"start_time": "2024-03-08T12:03:58.831359900Z"
}
},
"id": "bd8e6654e1c793e"
},
{
"cell_type": "code",
"execution_count": 210,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CRS of the uploaded Shapefile: EPSG:32188\n"
]
}
],
"source": [
"import geopandas as gpd\n",
"\n",
"# Load the Shapefile\n",
"gdf = gpd.read_file(roads_file)\n",
"\n",
"# Print the CRS\n",
"print(\"CRS of the uploaded Shapefile:\", gdf.crs)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-08T11:49:35.006423500Z",
"start_time": "2024-03-08T11:49:19.156474Z"
}
},
"id": "2de2020791b7c47a"
},
{
"cell_type": "code",
"execution_count": 221,
"outputs": [
{
"data": {
"text/plain": "<folium.folium.Map at 0x1ef9a47b460>",
"text/html": "<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><span style=\"color:#565656\">Make this Notebook Trusted to load map: File -> Trust Notebook</span><iframe srcdoc=\"&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n \n &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;\n \n &lt;script&gt;\n L_NO_TOUCH = false;\n L_DISABLE_3D = false;\n &lt;/script&gt;\n \n &lt;style&gt;html, body {width: 100%;height: 100%;margin: 0;padding: 0;}&lt;/style&gt;\n &lt;style&gt;#map {position:absolute;top:0;bottom:0;right:0;left:0;}&lt;/style&gt;\n &lt;script src=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.9.3/dist/leaflet.js&quot;&gt;&lt;/script&gt;\n &lt;script src=&quot;https://code.jquery.com/jquery-3.7.1.min.js&quot;&gt;&lt;/script&gt;\n &lt;script src=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js&quot;&gt;&lt;/script&gt;\n &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js&quot;&gt;&lt;/script&gt;\n &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.9.3/dist/leaflet.css&quot;/&gt;\n &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css&quot;/&gt;\n &lt;link rel=&quot;stylesheet&quot; href=&quot;https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css&quot;/&gt;\n &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.2.0/css/all.min.css&quot;/&gt;\n &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css&quot;/&gt;\n &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css&quot;/&gt;\n \n &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,\n initial-scale=1.0, maximum-scale=1.0, user-scalable=no&quot; /&gt;\n &lt;style&gt;\n #map_bd9ebef9bfbe392bf2340372d38a09dd {\n position: relative;\n width: 100.0%;\n height: 100.0%;\n left: 0.0%;\n top: 0.0%;\n }\n .leaflet-container { font-size: 1rem; }\n &lt;/style&gt;\n \n&lt;/head&gt;\n&lt;body&gt;\n \n \n &lt;div class=&quot;folium-map&quot; id=&quot;map_bd9ebef9bfbe392bf2340372d38a09dd&quot; &gt;&lt;/div&gt;\n \n&lt;/body&gt;\n&lt;script&gt;\n \n \n var map_bd9ebef9bfbe392bf2340372d38a09dd = L.map(\n &quot;map_bd9ebef9bfbe392bf2340372d38a09dd&quot;,\n {\n center: [45.50168587648179, -73.64755451613532],\n crs: L.CRS.EPSG3857,\n zoom: 15,\n zoomControl: true,\n preferCanvas: false,\n }\n );\n\n \n\n \n \n var tile_layer_d91b9e8dbaeebd6261467e2701229e32 = L.tileLayer(\n &quot;https://tile.openstreetmap.org/{z}/{x}/{y}.png&quot;,\n {&quot;attribution&quot;: &quot;\\u0026copy; \\u003ca href=\\&quot;https://www.openstreetmap.org/copyright\\&quot;\\u003eOpenStreetMap\\u003c/a\\u003e contributors&quot;, &quot;detectRetina&quot;: false, &quot;maxNativeZoom&quot;: 19, &quot;maxZoom&quot;: 19, &quot;minZoom&quot;: 0, &quot;noWrap&quot;: false, &quot;opacity&quot;: 1, &quot;subdomains&quot;: &quot;abc&quot;, &quot;tms&quot;: false}\n );\n \n \n tile_layer_d91b9e8dbaeebd6261467e2701229e32.addTo(map_bd9ebef9bfbe392bf2340372d38a09dd);\n \n \n var marker_825e9572e54304c7196c60fa737f5a1a = L.marker(\n [45.50168587648179, -73.64755451613532],
},
"execution_count": 221,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import folium\n",
"\n",
"# Initialize the map centered around the first node (adjust as necessary)\n",
"first_node = list(di_graph.nodes(data=True))[0]\n",
"center_lat, center_lon = di_graph.nodes[first_node[0]]['lat'], di_graph.nodes[first_node[0]]['lon']\n",
"m = folium.Map(location=[center_lat, center_lon], zoom_start=15)\n",
"\n",
"# Add nodes to the map\n",
"for node, data in di_graph.nodes(data=True):\n",
" folium.Marker(\n",
" location=[data['lat'], data['lon']],\n",
" popup=f\"Temperature: {data.get('temperature_history', 'N/A')}, Peak Demand: {data.get('Peack_Demand', 'N/A')}\",\n",
" icon=folium.Icon(color=\"red\", icon=\"info-sign\"),\n",
" ).add_to(m)\n",
"\n",
"# Add edges to the map\n",
"for u, v, data in di_graph.edges(data=True):\n",
" u_lat, u_lon = di_graph.nodes[u]['lat'], di_graph.nodes[u]['lon']\n",
" v_lat, v_lon = di_graph.nodes[v]['lat'], di_graph.nodes[v]['lon']\n",
" folium.PolyLine(\n",
" locations=[[u_lat, u_lon], [v_lat, v_lon]],\n",
" color=\"blue\",\n",
" weight=3,\n",
" tooltip=f\"Mass flow rate: {data['mass_flow_rate_actual']}\",\n",
" ).add_to(m)\n",
"\n",
"# Display the map\n",
"m"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-08T12:04:07.033537700Z",
"start_time": "2024-03-08T12:04:06.052123300Z"
}
},
"id": "a72386d5f2bc8e60"
},
{
"cell_type": "code",
"execution_count": 228,
"outputs": [],
"source": [
"# Assuming 'm' is your Folium map object\n",
"m.save(\"map.html\")"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-08T12:11:41.406508800Z",
"start_time": "2024-03-08T12:11:40.559166300Z"
}
},
"id": "e41182f9b4ca22d8"
},
{
"cell_type": "code",
"execution_count": 229,
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\majidr\\AppData\\Local\\Temp\\ipykernel_8776\\1404096142.py:23: MatplotlibDeprecationWarning:\n",
"\n",
"Unable to determine Axes to steal space for Colorbar. Using gca(), but will raise in the future. Either provide the *cax* argument to use as the Axes for the Colorbar, provide the *ax* argument to steal space from it, or add *mappable* to an Axes.\n",
"\n"
]
},
{
"data": {
"text/plain": "<Figure size 1000x800 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vvfQSK1asoEmTJoD352DBggVccskltGjRgm3btjF16lSGDRvG2rVriY6OZsiQIdxxxx288sorPPzww3Tp0gWg8n+rKysrY9iwYWzatInbbruNNm3a8Nlnn3H11VeTn5/PnXfeaXj8jBkzKCoq4sYbb0TTNCZOnMgFF1zAli1biIiIOJq3TwghQp8SQhyR9957TwFqyZIlavPmzcpisag77rij8v6hQ4eqbt26Vf5727Ztymw2qwkTJhiO8/fffyuLxWIYP/PMM1VGRobPOSdNmqTMZrMqLCxUSin1yiuvqIyMDNWnTx/14IMPKqWU8ng8KiEhQd19992Vz+vVq5dKSUlR+/fvrxxbuXKlMplM6sorr6wce+yxxxSgLr30Up9zX3XVVSomJkYppdQff/yh4uPj1ZlnnqkcDsch36eVK1cqQN11110+9+3fv1/t3bu38uZ0OivvGzp0qALUG2+84fO80tJSn7Ebb7xRRUdHG+ZTcYwXXnihcszpdFa+Hy6XSyml1OzZsxWgunTpYpjDyy+/rAD1999/H/I1ut1u1bx5c9W/f3/D+BtvvKEA9fPPP1eOVfzcbN26VSml1Jdffln5c1STivnNnj3bML5161YFqPfee69yzN978/HHHytAzZ07t8Z5KOV9v4YOHVrjPD799FMFqCeeeOKQ5/vzzz8VoD744IPKsc8++8zva/B33smTJytAffTRR5VjLpdL9e/fX8XGxlb+/Fe8/iZNmqjc3NzKx3799dcKUN9++22Nr0UIIcKVlMEIUQtt27bliiuu4K233iI7O9vvY7744gt0Xefiiy9m3759lbfU1FQ6dOjA7NmzD3uewYMH4/F4WLBgAeDNoA8ePJjBgwczb948AFavXk1+fj6DBw8GIDs7mxUrVnD11VeTlJRUeayePXty2mmn8cMPP/ic56abbqpxDrNnz2bEiBGceuqpfPHFF9hstkPOubCwEMBv28e2bduSnJxcefvmm28M99tsNq655hqf51XNUhcVFbFv3z4GDx5MaWkp69atMzzWYrFw4403Vv7barVy4403smfPHpYtW2Z47DXXXGOon654Dw/XqcZsNnPJJZfw559/Gso/ZsyYQbNmzTj11FNrfG5CQgIA3333HeXl5Yc8z5Go+t44HA727dtHv379AFi+fHmtj7t27VquvfZazj33XMaOHev3fOXl5ezfv5/27duTkJBQ6/P98MMPpKamcumll1aORUREcMcdd1BcXMycOXMMj//3v/9NYmJi5b+P9HMTQohwJMG6ELU0duxY3G53jbXrGzduRClFhw4dDAFqcnIy//zzj9965+pOOOEEoqOjKwPzimB9yJAhLF26FIfDUXlfRa15ZmYmAJ06dfI5XpcuXdi3bx8lJSWG8TZt2vg9v8Ph4Mwzz+T444/n008/PaKFgRU16v5q2r/++mt+/fVXnn/+eb/PTU9P93uONWvWcP7552O324mPjyc5OZnLL78cgIKCAsNj09LSfBbIduzYEcCnM0mrVq0M/64IAPPy8mp6eZUqFpDOmDEDgJ07dzJv3jwuueSSQy4oHTp0KBdeeCHjx4+nadOmnHvuubz33ns4nc7DntOf3Nxc7rzzTpo1a0ZUVBTJycmVn2f19+ZIFRYWcsEFF5Cens4HH3xgKKUpKytj3LhxtGzZEpvNRtOmTUlOTiY/P7/W58vMzKRDhw6YTMY/SRVlMxU/0xWO5XMTQohwIzXrQtRS27Ztufzyy3nrrbcYM2aMz/26rqNpGj/++KPf4O1INhyKiIigb9++zJ07l02bNpGTk8PgwYNp1qwZ5eXlLFq0iHnz5tG5c2eSk5Nr/Vpqqq+22WyMGjWKr7/+mp9++omzzjrrsMdq374
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import matplotlib.pyplot as plt\n",
"import networkx as nx\n",
"\n",
"pos = {node: (node[0], node[1]) for node in network_graph.nodes()}\n",
"\n",
"# Edges are colored based on their 'mass_flow_rate_peak' attribute\n",
"edge_colors = [network_graph[u][v]['mass_flow_rate_peak'] for u, v in network_graph.edges()]\n",
"\n",
"# Set up figure\n",
"plt.figure(figsize=(10, 8)) # Adjust figure size as needed\n",
"\n",
"# Drawing nodes with increased size for better visibility\n",
"nx.draw_networkx_nodes(network_graph, pos, node_size=100, node_color='skyblue', alpha=0.7)\n",
"\n",
"# Drawing edges with mass flow rate as colors and increased width for visibility\n",
"nx.draw_networkx_edges(network_graph, pos, edge_color=edge_colors, edge_cmap=plt.cm.plasma, width=3)\n",
"\n",
"# Optionally drawing labels with a smaller font size to prevent clutter\n",
"# nx.draw_networkx_labels(network_graph, pos, font_size=10, font_family=\"sans-serif\")\n",
"\n",
"# Adding a color bar to indicate the mass flow rate peak values\n",
"sm = plt.cm.ScalarMappable(cmap=plt.cm.plasma, norm=plt.Normalize(vmin=min(edge_colors), vmax=max(edge_colors)))\n",
"plt.colorbar(sm, label='Mass Flow Rate Peak')\n",
"\n",
"plt.title('Network Graph Visualization') # Add a title to the plot\n",
"plt.axis('off') # Turn off the axis\n",
"\n",
"# Save the figure\n",
"plt.savefig('network_graph_visualization.png', format='png', dpi=300) # Save as PNG with high dpi for clarity\n",
"\n",
"plt.show() # Show the plot\n"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-08T12:15:37.033575700Z",
"start_time": "2024-03-08T12:15:35.378548100Z"
}
},
"id": "7a94aa3a7057cda0"
},
{
"cell_type": "code",
"execution_count": 253,
"outputs": [
{
"data": {
"text/plain": "0 01/01 01:00:00\n1 01/01 02:00:00\n2 01/01 03:00:00\n3 01/01 04:00:00\n4 01/01 05:00:00\n ... \n8755 12/31 20:00:00\n8756 12/31 21:00:00\n8757 12/31 22:00:00\n8758 12/31 23:00:00\n8759 12/31 00:00:00\nName: Date/Time, Length: 8760, dtype: object"
},
"execution_count": 253,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# Step 1: Read the CSV file\n",
"df = pd.read_csv('./out_files/Mont-Royal_out.csv')\n",
"df[\"Date/Time\"] = df[\"Date/Time\"].str.replace(\"24:00:00\", \"00:00:00\")\n",
"df['Date/Time']\n"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-08T13:18:51.240886Z",
"start_time": "2024-03-08T13:18:50.011359200Z"
}
},
"id": "8c01118fa71e594b"
},
{
"cell_type": "code",
"execution_count": 254,
"outputs": [
{
"data": {
"text/plain": "0 2024/01/0101:00:00\n1 2024/01/0102:00:00\n2 2024/01/0103:00:00\n3 2024/01/0104:00:00\n4 2024/01/0105:00:00\n ... \n8755 2024/12/3120:00:00\n8756 2024/12/3121:00:00\n8757 2024/12/3122:00:00\n8758 2024/12/3123:00:00\n8759 2024/12/3100:00:00\nName: Date/Time, Length: 8760, dtype: object"
},
"execution_count": 254,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df['Date/Time'] = '2024/' + df['Date/Time']\n",
"df['Date/Time'] = df['Date/Time'].str.replace(' ', '')\n",
"df['Date/Time']"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-08T13:18:56.403897100Z",
"start_time": "2024-03-08T13:18:55.717607Z"
}
},
"id": "13216ced51acded9"
},
{
"cell_type": "code",
"execution_count": 255,
"outputs": [
{
"data": {
"text/plain": "0 2024-01-01 01:00:00\n1 2024-01-01 02:00:00\n2 2024-01-01 03:00:00\n3 2024-01-01 04:00:00\n4 2024-01-01 05:00:00\n ... \n8755 2024-12-31 20:00:00\n8756 2024-12-31 21:00:00\n8757 2024-12-31 22:00:00\n8758 2024-12-31 23:00:00\n8759 2024-12-31 00:00:00\nName: Date/Time, Length: 8760, dtype: datetime64[ns]"
},
"execution_count": 255,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df['Date/Time'] = pd.to_datetime(df['Date/Time'], format='%Y/%m/%d%H:%M:%S')\n",
"df[\"Date/Time\"]"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-08T13:19:00.519383Z",
"start_time": "2024-03-08T13:19:00.224258100Z"
}
},
"id": "986a986ce504635"
},
{
"cell_type": "code",
"execution_count": 257,
"outputs": [],
"source": [],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-08T13:24:51.724024500Z",
"start_time": "2024-03-08T13:24:50.790106800Z"
}
},
"id": "321d797a408f54cd"
},
{
"cell_type": "code",
"execution_count": 262,
"outputs": [
{
"data": {
"text/plain": "<Figure size 1000x600 with 0 Axes>"
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": "<Figure size 640x480 with 1 Axes>",
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAkEAAAHwCAYAAAChervgAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8pXeV/AAAACXBIWXMAAA9hAAAPYQGoP6dpAACSUUlEQVR4nOzdd1QUZ9sG8GtAaQqoqIiIotgV7AUr9l6jb2LvJsZYYmKMacYYe4u9xlgSSzSWJBoJmmCJ2MUusWGnWABB6ff3Bx8Tlt1VWBZ2ket3Dkd36rVldu595pkZRUQERERERHmMhakDEBEREZkCiyAiIiLKk1gEERERUZ7EIoiIiIjyJBZBRERElCexCCIiIqI8iUUQERER5UksgoiIiChPYhFEREREeVI+Uwcg86UoUzUe//BDNwweXDNTywgOjkDZsos0hv399yD4+LhnMR29yb7+2h9Tpx5SH5cp44jg4PGmCwRgy5aL+OGHQJw/H4qnT18iMTFZHXf79ji4uxfKkRz+/sFo0WKDxrCcXD8ZZv36QAwZskdjmMgUjcc+Putx6NAd9fGgQTWwfn33TK/L3f073LkTqT6eMqU5vv7aR33Mz9B/8nQRlP4Dl2r69Jb47LOmeudr02YTDhy4pTU8/QfN3OzefQ2BgSHqY3f3QpkuanIrXV9AAJA/vwWsrCzh4GCN4sULwMOjCOrVK4m+fT1RurSjCZKSOZowwRcLFx43eH5dO53MMvfvF3Oi68dXWvnzW6BgQSuULu2ImjVLoHv3yujWrRIURcnBlGQO8nQRpM/KlacxaVJjWFpqHy28ejVcZwGUG+zefQ0bNpxXHzdvXibPFEH6JCQkIyEhGTExCXj0KBrnz4di586r+OKLv9CjRxUsW9YRxYsXMHVMMqG7dyOxaNEJU8cgI0pISMazZ7F49iwW58+HYsOG82jSpDR++60PChWyMXU8ykEsgn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j33+fZGqZY8dqvo6//HIVz5691BiW2nSd1tChNTO1nswoXNgWI0dqFiwiKZ+BtFavPoNhw37VKoDSi4tLwvDhv2HTptcfSl2x4rRGAZTWkycv0a/fTvTs+bNGAZTW/ftR+PTTg69djz4iwIIFx/H996//zB49eveVfeQuXw7H7NlHtYZPm3ZYqwBKa9++60bpiJxd25856t9/p0YBlFZ8fBJGjvwNSUnJOsenNXz4b3oLIAD4/PO/8MUXf2sVL+lFRMSiR49t+Pvv29myDENER8cjODgCwcERuHIlHPPmHdNoBQKA1q3LwcbGfNsGYmMT0bXrVo0CKK3ExGQMH/4rQkKijb5uQ7f3GTOOaBVAaR05cve12/uyZa/e52UFi6B0Ro+uD0vLlJ8HL14kYN26cwCAxYv/e5MqVCiCDh3Kv3ZZv/xyFTt2XNEYVq1aMeze/TYuXHgPGzZ0R7Fims29U6b448aNp69crgjg4VEYe/a8g4sXR2HqVB+taTZvvqj+f+vWXrh9exzeequKxjQNGrji9u1xGn8NG2o3m6dKSEhGnTou8PMbgMDAdzF6dD2N8cnJgm3b9O/cdGnRoiw8Pf875Bgbm6jV7+r33//VKDTKlSuc7R0MdS3/3Ln/Li/w8OFzjB+/X2N8+/bl8ccf/XDt2mj4+w9C9+6VNcaPGfOHVoGXnkhK/5FDhwbj3Ll3tX4FX7wYhsePX6Bz54o4eXI4jh0bqtVqsn37ZSQkJGkMs7KyRMuWZbFgQVvs3dsXJ08Ox/XrY3D27Ehs3Ngd1aoV05h+7txjr8yZmrVAgfxYtqwjrlx5Hz/91BMODtYa02zerPl5CA+PwaxZml+UdnYpyzh//j3s2fMOKlcu+trCMiOyuv2NH98Qt2+Pw9y5bbSWnXab2bq1V5a
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"monthly_demand = df.resample('M').sum()[[\n",
" '195043 IDEAL LOADS AIR SYSTEM:Zone Ideal Loads Supply Air Total Heating Energy [J](Hourly)',\n",
" '195047 IDEAL LOADS AIR SYSTEM:Zone Ideal Loads Supply Air Total Heating Energy [J](Hourly)',\n",
" '195066 IDEAL LOADS AIR SYSTEM:Zone Ideal Loads Supply Air Total Heating Energy [J](Hourly)'\n",
"]]\n",
"\n",
"# Plotting with seaborn style\n",
"plt.figure(figsize=(10, 6))\n",
"\n",
"\n",
"# Plotting\n",
"ax = monthly_demand.plot(kind='bar', colormap='Set3')\n",
"ax.set_title('Monthly Demand of Three Buildings', fontsize=18, fontweight='bold', color='navy') # Set title properties\n",
"ax.set_xlabel('Month', fontsize=14, fontweight='bold', color='navy') # Set xlabel properties\n",
"ax.set_ylabel('Demand (Joules)', fontsize=14, fontweight='bold', color='navy') # Set ylabel properties\n",
"ax.set_xticklabels([x.strftime('%b') for x in monthly_demand.index], rotation=45) # Format xticklabels\n",
"\n",
"# Set legend labels and position\n",
"ax.legend([\"Building One\", \"Building Two\", \"Building Three\"], loc='upper right', fontsize=12)\n",
"\n",
"# Adjust background color and grid color\n",
"ax.set_facecolor('#f7f7f7') # Light gray background\n",
"ax.grid(color='white', linestyle='-', linewidth=1) # White grid lines\n",
"\n",
"# Save the figure\n",
"plt.savefig('monthly_demand_three_buildings.png', bbox_inches='tight')\n",
"\n",
"plt.show()"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-08T13:28:56.676265500Z",
"start_time": "2024-03-08T13:28:55.522179900Z"
}
},
"id": "41e381513cffb37d"
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [],
"metadata": {
"collapsed": false
},
"id": "1d35605b1a31bf80"
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}