-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic Jupyter notebook for sim-bench conversion
Signed-off-by: Bram Stoeller <[email protected]>
- Loading branch information
1 parent
df62469
commit a68bf5b
Showing
2 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "96e4fce1", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Imports\n", | ||
"from pathlib import Path\n", | ||
"from power_grid_model import PowerGridModel\n", | ||
"from power_grid_model_io.converters.pgm_json_converter import PgmJsonConverter\n", | ||
"from power_grid_model_io.converters.sim_bench_converter import SimBenchConverter" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "cf28c2c6", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Load source\n", | ||
"simbench_code = \"1-complete_data-mixed-all-0-sw\"\n", | ||
"simbench_converter = SimBenchConverter(simbench_code)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "fcedddf5", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Convert to PGM\n", | ||
"input_data, extra_info = simbench_converter.load_input_data()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "237b3557", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Store the source data in JSON format\n", | ||
"converter = PgmJsonConverter(destination_file=f\"data/sim-bench/{simbench_code}_input.json\")\n", | ||
"converter.save(data=input_data, extra_info=extra_info)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "3cf1dab7", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Perform power flow calculation\n", | ||
"grid = PowerGridModel(input_data=input_data)\n", | ||
"output_data = grid.calculate_power_flow()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "315649ed", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Store the result data in JSON format\n", | ||
"converter = PgmJsonConverter(destination_file=f\"data/sim-bench/{simbench_code}_output.json\")\n", | ||
"converter.save(data=output_data, extra_info=extra_info)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.5" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model project <[email protected]> | ||
|
||
SPDX-License-Identifier: MPL-2.0 |