diff --git a/Power Grid Model Benchmark.ipynb b/Power Grid Model Benchmark.ipynb index a5c059a..62cd903 100644 --- a/Power Grid Model Benchmark.ipynb +++ b/Power Grid Model Benchmark.ipynb @@ -76,7 +76,14 @@ "cell_type": "code", "execution_count": 1, "id": "0267ac98", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:38:44.431561Z", + "iopub.status.busy": "2024-11-29T08:38:44.431043Z", + "iopub.status.idle": "2024-11-29T08:38:45.399827Z", + "shell.execute_reply": "2024-11-29T08:38:45.399154Z" + } + }, "outputs": [], "source": [ "import time\n", @@ -113,7 +120,14 @@ "cell_type": "code", "execution_count": 2, "id": "34db0eaa", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:38:45.401904Z", + "iopub.status.busy": "2024-11-29T08:38:45.401649Z", + "iopub.status.idle": "2024-11-29T08:38:45.405414Z", + "shell.execute_reply": "2024-11-29T08:38:45.404941Z" + } + }, "outputs": [], "source": [ "# summary\n", @@ -160,7 +174,14 @@ "cell_type": "code", "execution_count": 3, "id": "ece0138d", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:38:45.407480Z", + "iopub.status.busy": "2024-11-29T08:38:45.406998Z", + "iopub.status.idle": "2024-11-29T08:38:45.410196Z", + "shell.execute_reply": "2024-11-29T08:38:45.409690Z" + } + }, "outputs": [], "source": [ "# fictional grid parameters\n", @@ -186,7 +207,14 @@ "cell_type": "code", "execution_count": 4, "id": "19a1b1f3", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:38:45.412047Z", + "iopub.status.busy": "2024-11-29T08:38:45.411578Z", + "iopub.status.idle": "2024-11-29T08:38:45.414259Z", + "shell.execute_reply": "2024-11-29T08:38:45.413765Z" + } + }, "outputs": [], "source": [ "# override small network\n", @@ -200,7 +228,14 @@ "cell_type": "code", "execution_count": 5, "id": "8301d2a0", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:38:45.415710Z", + "iopub.status.busy": "2024-11-29T08:38:45.415500Z", + "iopub.status.idle": "2024-11-29T08:38:45.418018Z", + "shell.execute_reply": "2024-11-29T08:38:45.417550Z" + } + }, "outputs": [], "source": [ "# derived values\n", @@ -226,7 +261,14 @@ "cell_type": "code", "execution_count": 6, "id": "cc656c47", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:38:45.419834Z", + "iopub.status.busy": "2024-11-29T08:38:45.419441Z", + "iopub.status.idle": "2024-11-29T08:38:46.565651Z", + "shell.execute_reply": "2024-11-29T08:38:46.564973Z" + } + }, "outputs": [], "source": [ "fictional_dataset = generate_fictional_grid(\n", @@ -263,6 +305,12 @@ "execution_count": 7, "id": "7909cdd9", "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:38:46.567540Z", + "iopub.status.busy": "2024-11-29T08:38:46.567394Z", + "iopub.status.idle": "2024-11-29T08:38:47.771192Z", + "shell.execute_reply": "2024-11-29T08:38:47.770435Z" + }, "scrolled": true }, "outputs": [], @@ -291,7 +339,14 @@ "cell_type": "code", "execution_count": 8, "id": "5251e4b0", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:38:47.773508Z", + "iopub.status.busy": "2024-11-29T08:38:47.772895Z", + "iopub.status.idle": "2024-11-29T08:38:48.852529Z", + "shell.execute_reply": "2024-11-29T08:38:48.851742Z" + } + }, "outputs": [], "source": [ "# initialize DSS\n", @@ -312,7 +367,14 @@ "cell_type": "code", "execution_count": 9, "id": "2540d408", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:38:48.854511Z", + "iopub.status.busy": "2024-11-29T08:38:48.854362Z", + "iopub.status.idle": "2024-11-29T08:38:48.858304Z", + "shell.execute_reply": "2024-11-29T08:38:48.857712Z" + } + }, "outputs": [], "source": [ "def benchmark_pgm_power_flow(symmetric: bool, calculation_type: str, update_data=None, with_intialization: bool = False):\n", @@ -332,7 +394,7 @@ " symmetric=symmetric, \n", " calculation_method=method, \n", " update_data=update_data, \n", - " output_component_types=['node', 'line'])\n", + " output_component_types={'node': [\"u_pu\"], 'line': [\"loading\"]})\n", " end = time.time()\n", " summary_df.loc[calculation_type, method_dict[method]] = end - start\n", " return pgm_result" @@ -368,7 +430,14 @@ "cell_type": "code", "execution_count": 10, "id": "612d3384", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:38:48.860018Z", + "iopub.status.busy": "2024-11-29T08:38:48.859750Z", + "iopub.status.idle": "2024-11-29T08:38:48.873348Z", + "shell.execute_reply": "2024-11-29T08:38:48.872745Z" + } + }, "outputs": [], "source": [ "benchmark_pgm_power_flow(symmetric=True, calculation_type='Symmetric calculation with solver initialization', with_intialization=True)\n", @@ -387,7 +456,14 @@ "cell_type": "code", "execution_count": 11, "id": "75a86adc", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:38:48.875330Z", + "iopub.status.busy": "2024-11-29T08:38:48.874960Z", + "iopub.status.idle": "2024-11-29T08:38:48.901386Z", + "shell.execute_reply": "2024-11-29T08:38:48.900738Z" + } + }, "outputs": [], "source": [ "# first calculation with solver initialization\n", @@ -415,7 +491,14 @@ "cell_type": "code", "execution_count": 12, "id": "f532a8ed", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:38:48.903484Z", + "iopub.status.busy": "2024-11-29T08:38:48.903016Z", + "iopub.status.idle": "2024-11-29T08:38:48.906825Z", + "shell.execute_reply": "2024-11-29T08:38:48.906374Z" + } + }, "outputs": [], "source": [ "comparison_df.loc['Symmetric calculation', 'Deviation Voltage (p.u.)'] = \\\n", @@ -444,7 +527,14 @@ "cell_type": "code", "execution_count": 13, "id": "c76f1366", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:38:48.908633Z", + "iopub.status.busy": "2024-11-29T08:38:48.908491Z", + "iopub.status.idle": "2024-11-29T08:38:48.934298Z", + "shell.execute_reply": "2024-11-29T08:38:48.933655Z" + } + }, "outputs": [], "source": [ "benchmark_pgm_power_flow(symmetric=False, calculation_type='Asymmetric calculation with solver initialization', with_intialization=True)\n", @@ -463,7 +553,14 @@ "cell_type": "code", "execution_count": 14, "id": "5357e649", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:38:48.936284Z", + "iopub.status.busy": "2024-11-29T08:38:48.936147Z", + "iopub.status.idle": "2024-11-29T08:38:49.771629Z", + "shell.execute_reply": "2024-11-29T08:38:49.771044Z" + } + }, "outputs": [], "source": [ "# first calculation with solver initialization\n", @@ -491,7 +588,14 @@ "cell_type": "code", "execution_count": 15, "id": "44b41b82", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:38:49.774704Z", + "iopub.status.busy": "2024-11-29T08:38:49.773894Z", + "iopub.status.idle": "2024-11-29T08:38:49.809094Z", + "shell.execute_reply": "2024-11-29T08:38:49.808555Z" + } + }, "outputs": [], "source": [ "# first calculation with solver initialization\n", @@ -521,7 +625,14 @@ "cell_type": "code", "execution_count": 16, "id": "840e9f29", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:38:49.812247Z", + "iopub.status.busy": "2024-11-29T08:38:49.811483Z", + "iopub.status.idle": "2024-11-29T08:38:49.818204Z", + "shell.execute_reply": "2024-11-29T08:38:49.817739Z" + } + }, "outputs": [], "source": [ "comparison_df.loc['Asymmetric calculation', 'Deviation Voltage (p.u.)'] = \\\n", @@ -550,7 +661,14 @@ "cell_type": "code", "execution_count": 17, "id": "ab571db2", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:38:49.820942Z", + "iopub.status.busy": "2024-11-29T08:38:49.820216Z", + "iopub.status.idle": "2024-11-29T08:38:49.839617Z", + "shell.execute_reply": "2024-11-29T08:38:49.839001Z" + } + }, "outputs": [], "source": [ "\n", @@ -589,7 +707,14 @@ "cell_type": "code", "execution_count": 18, "id": "bae29ebf", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:38:49.843185Z", + "iopub.status.busy": "2024-11-29T08:38:49.842471Z", + "iopub.status.idle": "2024-11-29T08:38:50.962899Z", + "shell.execute_reply": "2024-11-29T08:38:50.962227Z" + } + }, "outputs": [], "source": [ "pgm_result = benchmark_pgm_power_flow(symmetric=True, calculation_type='Time series symmetric calculation', update_data=pgm_update_dataset)\n", @@ -608,16 +733,15 @@ "cell_type": "code", "execution_count": 19, "id": "b943bdee", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "100%|██████████████████████████████████████████████████████████████████| 1000/1000 [00:14<00:00, 70.01it/s]\n" - ] + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:38:50.965184Z", + "iopub.status.busy": "2024-11-29T08:38:50.965042Z", + "iopub.status.idle": "2024-11-29T08:39:03.562681Z", + "shell.execute_reply": "2024-11-29T08:39:03.562003Z" } - ], + }, + "outputs": [], "source": [ "pp.timeseries.OutputWriter(\n", " pp_net,\n", @@ -630,7 +754,8 @@ "start = time.time()\n", "pp.timeseries.run_timeseries(\n", " pp_net, run=pp.runpp, time_steps=time_steps,\n", - " calculate_voltage_angles=True, distributed_slack=True, lightsim2grid=use_lightsim2grid\n", + " calculate_voltage_angles=True, distributed_slack=True, lightsim2grid=use_lightsim2grid,\n", + " verbose=False\n", ")\n", "end = time.time()\n", "summary_df.loc['Time series symmetric calculation', 'PandaPower Newton-Raphson'] = end - start" @@ -648,7 +773,14 @@ "cell_type": "code", "execution_count": 20, "id": "75977fb6", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:39:03.564815Z", + "iopub.status.busy": "2024-11-29T08:39:03.564432Z", + "iopub.status.idle": "2024-11-29T08:39:03.573307Z", + "shell.execute_reply": "2024-11-29T08:39:03.572715Z" + } + }, "outputs": [], "source": [ "pp_u_pu = pp_net.output_writer.iloc[0, 0].output['res_bus.vm_pu'].to_numpy()\n", @@ -679,7 +811,14 @@ "cell_type": "code", "execution_count": 21, "id": "4735161f", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:39:03.575236Z", + "iopub.status.busy": "2024-11-29T08:39:03.574927Z", + "iopub.status.idle": "2024-11-29T08:39:08.175247Z", + "shell.execute_reply": "2024-11-29T08:39:08.174511Z" + } + }, "outputs": [], "source": [ "pgm_result = benchmark_pgm_power_flow(symmetric=False, calculation_type='Time series asymmetric calculation', update_data=pgm_update_dataset)\n" @@ -697,16 +836,15 @@ "cell_type": "code", "execution_count": 22, "id": "d1b2d792", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "100%|██████████████████████████████████████████████████████████████████| 1000/1000 [03:23<00:00, 4.92it/s]\n" - ] + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:39:08.177342Z", + "iopub.status.busy": "2024-11-29T08:39:08.177043Z", + "iopub.status.idle": "2024-11-29T08:44:52.536744Z", + "shell.execute_reply": "2024-11-29T08:44:52.536013Z" } - ], + }, + "outputs": [], "source": [ "del pp_net.output_writer\n", "ow = pp.timeseries.OutputWriter(pp_net)\n", @@ -723,7 +861,8 @@ " time_steps=time_steps,\n", " calculate_voltage_angles=True,\n", " distributed_slack=True, \n", - " lightsim2grid=use_lightsim2grid\n", + " lightsim2grid=use_lightsim2grid,\n", + " verbose=False\n", ")\n", "end = time.time()\n", "summary_df.loc['Time series asymmetric calculation', 'PandaPower Newton-Raphson'] = end - start" @@ -741,7 +880,14 @@ "cell_type": "code", "execution_count": 23, "id": "589779e3", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:44:52.541318Z", + "iopub.status.busy": "2024-11-29T08:44:52.540872Z", + "iopub.status.idle": "2024-11-29T08:44:54.876154Z", + "shell.execute_reply": "2024-11-29T08:44:54.875600Z" + } + }, "outputs": [], "source": [ "# first calculation with solver initialization\n", @@ -759,7 +905,14 @@ "cell_type": "code", "execution_count": 24, "id": "dd8c7169", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:44:54.878204Z", + "iopub.status.busy": "2024-11-29T08:44:54.877929Z", + "iopub.status.idle": "2024-11-29T08:44:54.904553Z", + "shell.execute_reply": "2024-11-29T08:44:54.903890Z" + } + }, "outputs": [], "source": [ "# get results\n", @@ -793,7 +946,14 @@ "cell_type": "code", "execution_count": 25, "id": "1a7f075f", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:44:54.906348Z", + "iopub.status.busy": "2024-11-29T08:44:54.906211Z", + "iopub.status.idle": "2024-11-29T08:44:54.944191Z", + "shell.execute_reply": "2024-11-29T08:44:54.943522Z" + } + }, "outputs": [], "source": [ "pp_u_pu = []\n", @@ -829,7 +989,14 @@ "cell_type": "code", "execution_count": 26, "id": "3bbe4faa", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:44:54.946579Z", + "iopub.status.busy": "2024-11-29T08:44:54.946150Z", + "iopub.status.idle": "2024-11-29T08:44:54.954672Z", + "shell.execute_reply": "2024-11-29T08:44:54.954201Z" + } + }, "outputs": [], "source": [ "# re-generate dataset\n", @@ -839,12 +1006,11 @@ "\n", "# update dataset for power grid model\n", "# disable one line per batch\n", - "pgm_line_profile = pgm.initialize_array(\"update\", \"line\", (n_line, n_line))\n", - "pgm_line_profile[\"id\"] = pgm_dataset[\"line\"][\"id\"]\n", - "pgm_line_profile[\"from_status\"] = 1\n", - "pgm_line_profile[\"to_status\"] = 1\n", - "np.fill_diagonal(pgm_line_profile[\"from_status\"], 0)\n", - "np.fill_diagonal(pgm_line_profile[\"to_status\"], 0)\n", + "pgm_line_profile = {\n", + " \"id\": pgm_dataset[\"line\"][\"id\"].reshape(-1, 1).copy(),\n", + " \"from_status\": np.zeros((n_line, 1), dtype=np.int8),\n", + " \"to_status\": np.zeros((n_line, 1), dtype=np.int8),\n", + "}\n", "pgm_update_dataset = {\"line\": pgm_line_profile}" ] }, @@ -868,7 +1034,14 @@ "cell_type": "code", "execution_count": 27, "id": "ab0c5fc2", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:44:54.956294Z", + "iopub.status.busy": "2024-11-29T08:44:54.956147Z", + "iopub.status.idle": "2024-11-29T08:44:57.160844Z", + "shell.execute_reply": "2024-11-29T08:44:57.160304Z" + } + }, "outputs": [], "source": [ "pgm_result = benchmark_pgm_power_flow(symmetric=True, calculation_type='N-1 symmetric calculation', update_data=pgm_update_dataset)\n" @@ -886,7 +1059,14 @@ "cell_type": "code", "execution_count": 28, "id": "d1a08656", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:44:57.162733Z", + "iopub.status.busy": "2024-11-29T08:44:57.162450Z", + "iopub.status.idle": "2024-11-29T08:45:07.538111Z", + "shell.execute_reply": "2024-11-29T08:45:07.537520Z" + } + }, "outputs": [], "source": [ "# prepare pandapower result dataset\n", @@ -924,7 +1104,14 @@ "cell_type": "code", "execution_count": 29, "id": "040c08a0", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:45:07.540220Z", + "iopub.status.busy": "2024-11-29T08:45:07.539987Z", + "iopub.status.idle": "2024-11-29T08:45:07.547779Z", + "shell.execute_reply": "2024-11-29T08:45:07.547271Z" + } + }, "outputs": [], "source": [ "comparison_df.loc['N-1 symmetric calculation', 'Deviation Voltage (p.u.)'] = \\\n", @@ -953,7 +1140,14 @@ "cell_type": "code", "execution_count": 30, "id": "c0e18e41", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:45:07.549688Z", + "iopub.status.busy": "2024-11-29T08:45:07.549410Z", + "iopub.status.idle": "2024-11-29T08:45:13.727396Z", + "shell.execute_reply": "2024-11-29T08:45:13.726880Z" + } + }, "outputs": [], "source": [ "pgm_result = benchmark_pgm_power_flow(symmetric=False, calculation_type='N-1 asymmetric calculation', update_data=pgm_update_dataset)\n" @@ -971,7 +1165,14 @@ "cell_type": "code", "execution_count": 31, "id": "65ecfde0", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:45:13.729245Z", + "iopub.status.busy": "2024-11-29T08:45:13.729091Z", + "iopub.status.idle": "2024-11-29T08:50:12.384705Z", + "shell.execute_reply": "2024-11-29T08:50:12.382776Z" + } + }, "outputs": [], "source": [ "%%capture\n", @@ -1011,7 +1212,14 @@ "cell_type": "code", "execution_count": 32, "id": "11accf7c", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:50:12.389336Z", + "iopub.status.busy": "2024-11-29T08:50:12.388341Z", + "iopub.status.idle": "2024-11-29T08:50:12.414752Z", + "shell.execute_reply": "2024-11-29T08:50:12.412629Z" + } + }, "outputs": [], "source": [ "comparison_df.loc['N-1 asymmetric calculation', 'Deviation Voltage (p.u.)'] = \\\n", @@ -1042,7 +1250,14 @@ "cell_type": "code", "execution_count": 33, "id": "300e650a", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:50:12.420008Z", + "iopub.status.busy": "2024-11-29T08:50:12.418763Z", + "iopub.status.idle": "2024-11-29T08:50:12.443004Z", + "shell.execute_reply": "2024-11-29T08:50:12.442420Z" + } + }, "outputs": [ { "data": { @@ -1073,38 +1288,38 @@ " \n", " \n", " Symmetric calculation\n", - " 1.627143e-12\n", - " 5.222212e-13\n", + " 1.623590e-12\n", + " 5.166423e-13\n", " NaN\n", " \n", " \n", " Asymmetric calculation\n", - " 5.796947e-10\n", - " 8.192199e-09\n", - " 5.401322e-09\n", + " 5.796954e-10\n", + " 8.192067e-09\n", + " 5.401338e-09\n", " \n", " \n", " Time series symmetric calculation\n", - " 1.774803e-12\n", - " 1.255385e-12\n", + " 1.783462e-12\n", + " 1.300737e-12\n", " NaN\n", " \n", " \n", " Time series asymmetric calculation\n", - " 5.894767e-10\n", - " 3.375882e-09\n", + " 5.894751e-10\n", + " 3.375877e-09\n", " 4.059398e-06\n", " \n", " \n", " N-1 symmetric calculation\n", - " 1.632916e-12\n", - " 5.740408e-13\n", + " 1.634692e-12\n", + " 6.065148e-13\n", " NaN\n", " \n", " \n", " N-1 asymmetric calculation\n", - " 5.797154e-10\n", - " 8.192231e-09\n", + " 5.797138e-10\n", + " 8.192209e-09\n", " NaN\n", " \n", " \n", @@ -1113,24 +1328,24 @@ ], "text/plain": [ " Deviation Voltage (p.u.) \\\n", - "Symmetric calculation 1.627143e-12 \n", - "Asymmetric calculation 5.796947e-10 \n", - "Time series symmetric calculation 1.774803e-12 \n", - "Time series asymmetric calculation 5.894767e-10 \n", - "N-1 symmetric calculation 1.632916e-12 \n", - "N-1 asymmetric calculation 5.797154e-10 \n", + "Symmetric calculation 1.623590e-12 \n", + "Asymmetric calculation 5.796954e-10 \n", + "Time series symmetric calculation 1.783462e-12 \n", + "Time series asymmetric calculation 5.894751e-10 \n", + "N-1 symmetric calculation 1.634692e-12 \n", + "N-1 asymmetric calculation 5.797138e-10 \n", "\n", " Deviation Loading (p.u.) \\\n", - "Symmetric calculation 5.222212e-13 \n", - "Asymmetric calculation 8.192199e-09 \n", - "Time series symmetric calculation 1.255385e-12 \n", - "Time series asymmetric calculation 3.375882e-09 \n", - "N-1 symmetric calculation 5.740408e-13 \n", - "N-1 asymmetric calculation 8.192231e-09 \n", + "Symmetric calculation 5.166423e-13 \n", + "Asymmetric calculation 8.192067e-09 \n", + "Time series symmetric calculation 1.300737e-12 \n", + "Time series asymmetric calculation 3.375877e-09 \n", + "N-1 symmetric calculation 6.065148e-13 \n", + "N-1 asymmetric calculation 8.192209e-09 \n", "\n", " Deviation Voltage (p.u.) OpenDSS \n", "Symmetric calculation NaN \n", - "Asymmetric calculation 5.401322e-09 \n", + "Asymmetric calculation 5.401338e-09 \n", "Time series symmetric calculation NaN \n", "Time series asymmetric calculation 4.059398e-06 \n", "N-1 symmetric calculation NaN \n", @@ -1159,7 +1374,14 @@ "cell_type": "code", "execution_count": 34, "id": "4f897355", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:50:12.449185Z", + "iopub.status.busy": "2024-11-29T08:50:12.445860Z", + "iopub.status.idle": "2024-11-29T08:50:12.461736Z", + "shell.execute_reply": "2024-11-29T08:50:12.460763Z" + } + }, "outputs": [ { "data": { @@ -1193,74 +1415,74 @@ " \n", " \n", " Symmetric calculation with solver initialization\n", - " 0.000650\n", - " 0.000702\n", - " 0.000815\n", - " 0.000686\n", - " 0.018638\n", + " 0.000659\n", + " 0.000547\n", + " 0.000900\n", + " 0.000631\n", + " 0.013300\n", " inf\n", " \n", " \n", " Symmetric calculation without solver initialization\n", - " 0.000190\n", - " 0.000284\n", - " 0.000564\n", - " 0.000742\n", - " 0.013096\n", + " 0.000299\n", + " 0.000261\n", + " 0.000514\n", + " 0.000371\n", + " 0.009773\n", " inf\n", " \n", " \n", " Asymmetric calculation with solver initialization\n", - " 0.001976\n", - " 0.001394\n", - " 0.002811\n", - " 0.001418\n", - " 0.594590\n", - " 0.018144\n", + " 0.001310\n", + " 0.001190\n", + " 0.002842\n", + " 0.001428\n", + " 0.641134\n", + " 0.027860\n", " \n", " \n", " Asymmetric calculation without solver initialization\n", - " 0.000794\n", - " 0.000795\n", - " 0.002003\n", - " 0.000924\n", - " 0.137374\n", - " 0.001243\n", + " 0.000781\n", + " 0.000691\n", + " 0.002256\n", + " 0.000982\n", + " 0.191105\n", + " 0.002102\n", " \n", " \n", " Time series symmetric calculation\n", - " 0.192804\n", - " 0.208759\n", - " 0.478408\n", - " 0.292400\n", - " 14.297663\n", + " 0.191180\n", + " 0.197543\n", + " 0.429694\n", + " 0.290849\n", + " 12.593469\n", " inf\n", " \n", " \n", " Time series asymmetric calculation\n", - " 0.692793\n", - " 0.702723\n", - " 2.191837\n", - " 0.966539\n", - " 203.143780\n", - " 2.431052\n", + " 0.650882\n", + " 0.658563\n", + " 2.344757\n", + " 0.931097\n", + " 344.354888\n", + " 2.330588\n", " \n", " \n", " N-1 symmetric calculation\n", - " 0.542643\n", - " 0.554907\n", - " 0.836441\n", - " 0.635951\n", - " 12.486265\n", + " 0.455257\n", + " 0.475543\n", + " 0.704983\n", + " 0.558368\n", + " 10.370726\n", " inf\n", " \n", " \n", " N-1 asymmetric calculation\n", - " 1.124304\n", - " 1.195040\n", - " 2.841185\n", - " 1.347059\n", - " 186.949392\n", + " 1.059141\n", + " 1.017584\n", + " 2.752947\n", + " 1.333205\n", + " 298.642300\n", " inf\n", " \n", " \n", @@ -1269,62 +1491,62 @@ ], "text/plain": [ " PGM Linear Impedance \\\n", - "Symmetric calculation with solver initialization 0.000650 \n", - "Symmetric calculation without solver initializa... 0.000190 \n", - "Asymmetric calculation with solver initialization 0.001976 \n", - "Asymmetric calculation without solver initializ... 0.000794 \n", - "Time series symmetric calculation 0.192804 \n", - "Time series asymmetric calculation 0.692793 \n", - "N-1 symmetric calculation 0.542643 \n", - "N-1 asymmetric calculation 1.124304 \n", + "Symmetric calculation with solver initialization 0.000659 \n", + "Symmetric calculation without solver initializa... 0.000299 \n", + "Asymmetric calculation with solver initialization 0.001310 \n", + "Asymmetric calculation without solver initializ... 0.000781 \n", + "Time series symmetric calculation 0.191180 \n", + "Time series asymmetric calculation 0.650882 \n", + "N-1 symmetric calculation 0.455257 \n", + "N-1 asymmetric calculation 1.059141 \n", "\n", " PGM Linear Current \\\n", - "Symmetric calculation with solver initialization 0.000702 \n", - "Symmetric calculation without solver initializa... 0.000284 \n", - "Asymmetric calculation with solver initialization 0.001394 \n", - "Asymmetric calculation without solver initializ... 0.000795 \n", - "Time series symmetric calculation 0.208759 \n", - "Time series asymmetric calculation 0.702723 \n", - "N-1 symmetric calculation 0.554907 \n", - "N-1 asymmetric calculation 1.195040 \n", + "Symmetric calculation with solver initialization 0.000547 \n", + "Symmetric calculation without solver initializa... 0.000261 \n", + "Asymmetric calculation with solver initialization 0.001190 \n", + "Asymmetric calculation without solver initializ... 0.000691 \n", + "Time series symmetric calculation 0.197543 \n", + "Time series asymmetric calculation 0.658563 \n", + "N-1 symmetric calculation 0.475543 \n", + "N-1 asymmetric calculation 1.017584 \n", "\n", " PGM Newton-Raphson \\\n", - "Symmetric calculation with solver initialization 0.000815 \n", - "Symmetric calculation without solver initializa... 0.000564 \n", - "Asymmetric calculation with solver initialization 0.002811 \n", - "Asymmetric calculation without solver initializ... 0.002003 \n", - "Time series symmetric calculation 0.478408 \n", - "Time series asymmetric calculation 2.191837 \n", - "N-1 symmetric calculation 0.836441 \n", - "N-1 asymmetric calculation 2.841185 \n", + "Symmetric calculation with solver initialization 0.000900 \n", + "Symmetric calculation without solver initializa... 0.000514 \n", + "Asymmetric calculation with solver initialization 0.002842 \n", + "Asymmetric calculation without solver initializ... 0.002256 \n", + "Time series symmetric calculation 0.429694 \n", + "Time series asymmetric calculation 2.344757 \n", + "N-1 symmetric calculation 0.704983 \n", + "N-1 asymmetric calculation 2.752947 \n", "\n", " PGM Iterative Current \\\n", - "Symmetric calculation with solver initialization 0.000686 \n", - "Symmetric calculation without solver initializa... 0.000742 \n", - "Asymmetric calculation with solver initialization 0.001418 \n", - "Asymmetric calculation without solver initializ... 0.000924 \n", - "Time series symmetric calculation 0.292400 \n", - "Time series asymmetric calculation 0.966539 \n", - "N-1 symmetric calculation 0.635951 \n", - "N-1 asymmetric calculation 1.347059 \n", + "Symmetric calculation with solver initialization 0.000631 \n", + "Symmetric calculation without solver initializa... 0.000371 \n", + "Asymmetric calculation with solver initialization 0.001428 \n", + "Asymmetric calculation without solver initializ... 0.000982 \n", + "Time series symmetric calculation 0.290849 \n", + "Time series asymmetric calculation 0.931097 \n", + "N-1 symmetric calculation 0.558368 \n", + "N-1 asymmetric calculation 1.333205 \n", "\n", " PandaPower Newton-Raphson \\\n", - "Symmetric calculation with solver initialization 0.018638 \n", - "Symmetric calculation without solver initializa... 0.013096 \n", - "Asymmetric calculation with solver initialization 0.594590 \n", - "Asymmetric calculation without solver initializ... 0.137374 \n", - "Time series symmetric calculation 14.297663 \n", - "Time series asymmetric calculation 203.143780 \n", - "N-1 symmetric calculation 12.486265 \n", - "N-1 asymmetric calculation 186.949392 \n", + "Symmetric calculation with solver initialization 0.013300 \n", + "Symmetric calculation without solver initializa... 0.009773 \n", + "Asymmetric calculation with solver initialization 0.641134 \n", + "Asymmetric calculation without solver initializ... 0.191105 \n", + "Time series symmetric calculation 12.593469 \n", + "Time series asymmetric calculation 344.354888 \n", + "N-1 symmetric calculation 10.370726 \n", + "N-1 asymmetric calculation 298.642300 \n", "\n", " OpenDSS Fix Point \n", "Symmetric calculation with solver initialization inf \n", "Symmetric calculation without solver initializa... inf \n", - "Asymmetric calculation with solver initialization 0.018144 \n", - "Asymmetric calculation without solver initializ... 0.001243 \n", + "Asymmetric calculation with solver initialization 0.027860 \n", + "Asymmetric calculation without solver initializ... 0.002102 \n", "Time series symmetric calculation inf \n", - "Time series asymmetric calculation 2.431052 \n", + "Time series asymmetric calculation 2.330588 \n", "N-1 symmetric calculation inf \n", "N-1 asymmetric calculation inf " ] @@ -1341,103 +1563,110 @@ "cell_type": "code", "execution_count": 35, "id": "6c921324", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-29T08:50:12.464166Z", + "iopub.status.busy": "2024-11-29T08:50:12.463942Z", + "iopub.status.idle": "2024-11-29T08:50:12.500763Z", + "shell.execute_reply": "2024-11-29T08:50:12.500078Z" + } + }, "outputs": [ { "data": { "text/html": [ "\n", - "\n", + "
\n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", "
 PGM Linear ImpedancePGM Linear CurrentPGM Newton-RaphsonPGM Iterative CurrentPandaPower Newton-RaphsonOpenDSS Fix PointPGM Linear ImpedancePGM Linear CurrentPGM Newton-RaphsonPGM Iterative CurrentPandaPower Newton-RaphsonOpenDSS Fix Point
Symmetric calculation with solver initialization28.67x26.55x22.86x27.17x1.00x0.00xSymmetric calculation with solver initialization20.20x24.30x14.78x21.08x1.00x0.00x
Symmetric calculation without solver initialization68.75x46.12x23.22x17.65x1.00x0.00xSymmetric calculation without solver initialization32.66x37.40x19.00x26.34x1.00x0.00x
Asymmetric calculation with solver initialization300.83x426.60x211.51x419.35x1.00x32.77xAsymmetric calculation with solver initialization489.55x538.79x225.60x448.93x1.00x23.01x
Asymmetric calculation without solver initialization173.08x172.72x68.57x148.62x1.00x110.55xAsymmetric calculation without solver initialization244.75x276.59x84.69x194.65x1.00x90.91x
Time series symmetric calculation74.16x68.49x29.89x48.90x1.00x0.00xTime series symmetric calculation65.87x63.75x29.31x43.30x1.00x0.00x
Time series asymmetric calculation293.22x289.08x92.68x210.18x1.00x83.56xTime series asymmetric calculation529.06x522.89x146.86x369.84x1.00x147.75x
N-1 symmetric calculation23.01x22.50x14.93x19.63x1.00x0.00xN-1 symmetric calculation22.78x21.81x14.71x18.57x1.00x0.00x
N-1 asymmetric calculation166.28x156.44x65.80x138.78x1.00x0.00xN-1 asymmetric calculation281.97x293.48x108.48x224.00x1.00x0.00x
\n" ], "text/plain": [ - "" + "" ] }, "metadata": {}, @@ -1450,6 +1679,12 @@ "display(speedup_df.style.format(\"{:0.2f}x\"))" ] }, + { + "cell_type": "markdown", + "id": "37444b58", + "metadata": {}, + "source": [] + }, { "cell_type": "code", "execution_count": null, @@ -1461,7 +1696,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": ".venv", "language": "python", "name": "python3" }, @@ -1475,12 +1710,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "vscode": { - "interpreter": { - "hash": "28721edaad53f4f17a46e69ba9bd0e68a80bd49709109c11e752be628e2137ca" - } + "version": "3.12.7" } }, "nbformat": 4, diff --git a/generate_fictional_dataset.py b/generate_fictional_dataset.py index 67067ea..d91fb5a 100644 --- a/generate_fictional_dataset.py +++ b/generate_fictional_dataset.py @@ -135,18 +135,8 @@ def generate_fictional_grid( for line, line_length in zip(pgm_dataset["line"], length) } - n_load = n_node - 1 - # add sym load - pgm_dataset["sym_load"] = pgm.initialize_array("input", "sym_load", n_load) - pgm_dataset["sym_load"]["id"] = np.arange(n_node + n_line, n_node + n_line + n_load, dtype=np.int32) - pgm_dataset["sym_load"]["node"] = pgm_dataset["node"]["id"][1:] - pgm_dataset["sym_load"]["status"] = 1 - pgm_dataset["sym_load"]["type"] = pgm.LoadGenType.const_power - pgm_dataset["sym_load"]["p_specified"] = np.random.uniform( - low=load_p_w_min / 3.0, high=load_p_w_max / 3.0, size=n_load - ) - pgm_dataset["sym_load"]["q_specified"] = pgm_dataset["sym_load"]["p_specified"] * np.sqrt(1 - pf**2) / pf # add asym load + n_load = n_node - 1 # pgm pgm_dataset["asym_load"] = pgm.initialize_array("input", "asym_load", n_load) pgm_dataset["asym_load"]["id"] = np.arange(n_node + n_line, n_node + n_line + n_load, dtype=np.int32) @@ -235,10 +225,10 @@ def generate_fictional_grid( # pgm n_load = pgm_dataset["asym_load"].size scaling = np.random.uniform(low=load_scaling_min, high=load_scaling_max, size=(n_step, n_load, 3)) - asym_load_profile = pgm.initialize_array("update", "asym_load", (n_step, n_load)) - asym_load_profile["id"] = pgm_dataset["asym_load"]["id"].reshape(1, -1) - asym_load_profile["p_specified"] = pgm_dataset["asym_load"]["p_specified"].reshape(1, -1, 3) * scaling - asym_load_profile["q_specified"] = pgm_dataset["asym_load"]["q_specified"].reshape(1, -1, 3) * scaling + asym_load_profile = { + "p_specified": pgm_dataset["asym_load"]["p_specified"].reshape(1, -1, 3) * scaling, + "q_specified": pgm_dataset["asym_load"]["q_specified"].reshape(1, -1, 3) * scaling, + } # pp pp_dataset = {} diff --git a/requirements.txt b/requirements.txt index 2d07aaa..090408d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,10 +3,10 @@ # SPDX-License-Identifier: MPL-2.0 jupyter -numba~=0.56.0 +numba numpy pandapower -power-grid-model>=1.4 +power-grid-model>=1.10 lightsim2grid igraph pandas