Skip to content

Commit a68bf5b

Browse files
committed
Basic Jupyter notebook for sim-bench conversion
Signed-off-by: Bram Stoeller <bram.stoeller@alliander.com>
1 parent df62469 commit a68bf5b

File tree

2 files changed

+101
-0
lines changed

2 files changed

+101
-0
lines changed

docs/examples/sim_bench_example.ipynb

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"id": "96e4fce1",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"# Imports\n",
11+
"from pathlib import Path\n",
12+
"from power_grid_model import PowerGridModel\n",
13+
"from power_grid_model_io.converters.pgm_json_converter import PgmJsonConverter\n",
14+
"from power_grid_model_io.converters.sim_bench_converter import SimBenchConverter"
15+
]
16+
},
17+
{
18+
"cell_type": "code",
19+
"execution_count": null,
20+
"id": "cf28c2c6",
21+
"metadata": {},
22+
"outputs": [],
23+
"source": [
24+
"# Load source\n",
25+
"simbench_code = \"1-complete_data-mixed-all-0-sw\"\n",
26+
"simbench_converter = SimBenchConverter(simbench_code)"
27+
]
28+
},
29+
{
30+
"cell_type": "code",
31+
"execution_count": null,
32+
"id": "fcedddf5",
33+
"metadata": {},
34+
"outputs": [],
35+
"source": [
36+
"# Convert to PGM\n",
37+
"input_data, extra_info = simbench_converter.load_input_data()"
38+
]
39+
},
40+
{
41+
"cell_type": "code",
42+
"execution_count": null,
43+
"id": "237b3557",
44+
"metadata": {},
45+
"outputs": [],
46+
"source": [
47+
"# Store the source data in JSON format\n",
48+
"converter = PgmJsonConverter(destination_file=f\"data/sim-bench/{simbench_code}_input.json\")\n",
49+
"converter.save(data=input_data, extra_info=extra_info)"
50+
]
51+
},
52+
{
53+
"cell_type": "code",
54+
"execution_count": null,
55+
"id": "3cf1dab7",
56+
"metadata": {},
57+
"outputs": [],
58+
"source": [
59+
"# Perform power flow calculation\n",
60+
"grid = PowerGridModel(input_data=input_data)\n",
61+
"output_data = grid.calculate_power_flow()"
62+
]
63+
},
64+
{
65+
"cell_type": "code",
66+
"execution_count": null,
67+
"id": "315649ed",
68+
"metadata": {},
69+
"outputs": [],
70+
"source": [
71+
"# Store the result data in JSON format\n",
72+
"converter = PgmJsonConverter(destination_file=f\"data/sim-bench/{simbench_code}_output.json\")\n",
73+
"converter.save(data=output_data, extra_info=extra_info)"
74+
]
75+
}
76+
],
77+
"metadata": {
78+
"kernelspec": {
79+
"display_name": "Python 3 (ipykernel)",
80+
"language": "python",
81+
"name": "python3"
82+
},
83+
"language_info": {
84+
"codemirror_mode": {
85+
"name": "ipython",
86+
"version": 3
87+
},
88+
"file_extension": ".py",
89+
"mimetype": "text/x-python",
90+
"name": "python",
91+
"nbconvert_exporter": "python",
92+
"pygments_lexer": "ipython3",
93+
"version": "3.10.5"
94+
}
95+
},
96+
"nbformat": 4,
97+
"nbformat_minor": 5
98+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model project <dynamic.grid.calculation@alliander.com>
2+
3+
SPDX-License-Identifier: MPL-2.0

0 commit comments

Comments
 (0)