{ "cells": [ { "cell_type": "markdown", "id": "d3852261", "metadata": {}, "source": [ "# Using power-grid-model for calculations" ] }, { "cell_type": "markdown", "id": "fdc5b02d", "metadata": {}, "source": [ "power-grid-model is a Python library for steady-state distribution power system analysis. The core of the library is written in C++. Using it for calculation can give a significant boost to performance, especially for asymmetric calculations. \n", "\n", "Currently power-grid-model supports limited components hence some of components or features are not supported. You can find the complete details about them [here](https://power-grid-model-io.readthedocs.io/en/stable/converters/pandapower_converter.html). An exception will be raised for them. " ] }, { "cell_type": "markdown", "id": "dbdfef8f", "metadata": {}, "source": [ "## Power flow calculation" ] }, { "cell_type": "markdown", "id": "0513d97e", "metadata": {}, "source": [ "First imports and initialize a basic network" ] }, { "cell_type": "code", "execution_count": null, "id": "49ae727b", "metadata": { "ExecuteTime": { "end_time": "2025-10-20T11:50:43.963587Z", "start_time": "2025-10-20T11:50:39.098103Z" } }, "outputs": [], "source": [ "from pandapower.run import runpp_pgm\n", "from pandapower.networks import example_simple\n", "import warnings\n", "warnings.simplefilter(action='ignore', category=FutureWarning)" ] }, { "cell_type": "code", "execution_count": null, "id": "a9d28d15b54962ef", "metadata": { "ExecuteTime": { "end_time": "2025-10-20T11:50:44.205928Z", "start_time": "2025-10-20T11:50:43.972097Z" } }, "outputs": [], "source": [ "net = example_simple()\n", "# Remove Generator since its not supported yet\n", "net[\"gen\"] = net[\"gen\"].iloc[:0]" ] }, { "cell_type": "markdown", "id": "b3e4879a", "metadata": {}, "source": [ "A powerflow can be run using power-grid-model for calculation by using the `pp.runpp_pgm` function. The function has its own arguments different from `pp.runpp()`" ] }, { "cell_type": "code", "execution_count": null, "id": "456b50b1", "metadata": { "ExecuteTime": { "end_time": "2025-10-20T11:50:44.300863Z", "start_time": "2025-10-20T11:50:44.214624Z" } }, "outputs": [], "source": [ "runpp_pgm(net)\n", "net.res_bus" ] }, { "cell_type": "markdown", "id": "78400d02", "metadata": {}, "source": [ "To know more about the library, refer to [power-grid-model](https://github.com/alliander-opensource/power-grid-model) and repository and [power-grid-model documentation](https://power-grid-model.readthedocs.io/en/stable/). The conversion from pandapower net to and from power-grid-model is handled by [power-grid-model-io](https://github.com/alliander-opensource/power-grid-model-io) ([power-grid-model-io documentation](https://power-grid-model-io.readthedocs.io/en/stable/)).\n", "\n", "The user however would usually not have to concern with these as power-grid-model is integrated into pandapower powerflow functions directly." ] } ], "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" } }, "nbformat": 4, "nbformat_minor": 5 }