Skip to content

Generic branch: examples #900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 13 additions & 18 deletions docs/examples/Generic Branch Example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -175,24 +175,24 @@
"\"\"\"\n",
"\n",
"\n",
"# Spannungsebenen des Transformators\n",
"# Voltage levels of the transformer\n",
"u_rated = {\"HV\": 200e3, \"MV\": 150e3, \"LV\": 30.2e3, \"AUX\": 200e3, \"Station1\": 150e3, \"Source\": 200e3}\n",
"\n",
"# Eingespeiste Leistung (200 kV) auf der 380 kV Seite\n",
"# Injected power (200 kV) on the 380 kV side\n",
"source_voltage = u_rated[\"Source\"] # 200 kV\n",
"source_power = 1e40 # hohe Kurzschlussleistung -> v_pu = 1.0\n",
"\n",
"# Lasten\n",
"# Loads\n",
"load_MV = {\"P\": 30e6, \"Q\": 5e6}\n",
"load_LV = {\"P\": 1.5e6, \"Q\": 0.15e6} # Eigenbedarf\n",
"\n",
"# Zuweisung der Knotennummern\n",
"# Assignment of node numbers\n",
"nodes = {\"HV\": 1, \"MV\": 2, \"LV\": 3, \"AUX\": 4, \"Station1\": 11, \"Source\": 14}\n",
"non = len(nodes) # number of nodes\n",
"# tap-changer\n",
"v_tap = 6.0e3\n",
"\n",
"# Generiere Knoten\n",
"# generated nodes\n",
"node_data = initialize_array(DatasetType.input, ComponentType.node, non)\n",
"node_data[\"id\"] = list(nodes.values())\n",
"node_data[\"u_rated\"] = list(u_rated.values())\n",
Expand All @@ -202,15 +202,15 @@
"\n",
"# node_data[\"u_rated\"] = [u_rated['HV'], u_rated['MV'], u_rated['LV'], u_rated['AUX'],u_rated['Station1'] ]\n",
"\n",
"# Quelle auf der 380kV-Seite (Slack)\n",
"# Slack\n",
"source_data = initialize_array(DatasetType.input, ComponentType.source, 1)\n",
"source_data[\"id\"] = [5]\n",
"source_data[\"node\"] = [nodes[\"Source\"]]\n",
"source_data[\"status\"] = [1]\n",
"source_data[\"u_ref\"] = [1.0]\n",
"source_data[\"sk\"] = [source_power]\n",
"\n",
"# Last auf der 110kV-Seite\n",
"# Loads 110kV\n",
"load_data = initialize_array(DatasetType.input, ComponentType.sym_load, 2)\n",
"load_data[\"id\"] = [6, 7]\n",
"load_data[\"type\"] = [LoadGenType.const_power, LoadGenType.const_power]\n",
Expand All @@ -222,10 +222,10 @@
"node_name = [\"HV\", \"MV\", \"LV\", \"AUX\", \"Station1\", \"Source\"]\n",
"branch_name = [\"BHV\", \"BMV\", \"BLV\", \"BLine2\", \"BLine1\"]\n",
"\n",
"# Generic Branch für jeden der zwei Wickler\n",
"\n",
"branch_data = initialize_array(DatasetType.input, ComponentType.generic_branch, 5)\n",
"\n",
"# Verbindungen der zwei Wickler\n",
"\n",
"branch_data[\"id\"] = [8, 9, 10, 12, 13]\n",
"branch_data[\"from_node\"] = [nodes[\"HV\"], nodes[\"AUX\"], nodes[\"AUX\"], nodes[\"MV\"], nodes[\"Source\"]]\n",
"branch_data[\"to_node\"] = [nodes[\"AUX\"], nodes[\"MV\"], nodes[\"LV\"], nodes[\"Station1\"], nodes[\"HV\"]]\n",
Expand All @@ -241,18 +241,17 @@
"branch_data[\"theta\"] = [0.0, 0.0, 0.0, 0.0, 0.0]\n",
"branch_data[\"sn\"] = [450e6, 450e6, 100e6, 100e6, 450e6]\n",
"\n",
"# Input-Daten sammeln\n",
"input_data = {\n",
" ComponentType.node: node_data,\n",
" ComponentType.source: source_data,\n",
" ComponentType.sym_load: load_data,\n",
" ComponentType.generic_branch: branch_data,\n",
"}\n",
"\n",
"# Überprüfung der Eingabedaten\n",
"\n",
"assert_valid_input_data(input_data=input_data, calculation_type=CalculationType.power_flow)\n",
"\n",
"# Power-Flow Modell erstellen und Berechnungen durchführen\n",
"\n",
"model = PowerGridModel(input_data)\n",
"output_data = model.calculate_power_flow(\n",
" symmetric=True, error_tolerance=1e-8, max_iterations=20, calculation_method=CalculationMethod.newton_raphson\n",
Expand Down Expand Up @@ -370,11 +369,10 @@
" genb_out = output_data[ComponentType.generic_branch]\n",
" df = pd.DataFrame(genb_out)\n",
"\n",
" # Summiere die aktive und reaktive Leistung über alle Branches hinweg\n",
" # Sum up the active and reactive performance across all branches\n",
" P_total = e6(df[\"p_from\"].sum()) + e6(df[\"p_to\"].sum())\n",
" Q_total = e6(df[\"q_from\"].sum()) + e6(df[\"q_to\"].sum())\n",
"\n",
" # Ausgabe der Gesamtsummen\n",
" print(\"\\nTotal Power for all Branches\")\n",
" print(\"----------------------------\")\n",
" print(f\"Total Active Power (P_total): {P_total:.2f} MW\")\n",
Expand All @@ -394,8 +392,6 @@
"print_load_input(input_data)\n",
"print_source_input(input_data)\n",
"\n",
"\n",
"# Ausgabe der Spannungen und Ströme\n",
"print(\"========================================\")\n",
"print(\" Output Data\")\n",
"print(\"========================================\")\n",
Expand Down Expand Up @@ -754,11 +750,10 @@
" genb_out = output_data[ComponentType.generic_branch]\n",
" df = pd.DataFrame(genb_out)\n",
"\n",
" # Summiere die aktive und reaktive Leistung über alle Branches hinweg\n",
" # Sum up the active and reactive performance across all branches\n",
" P_total = e6(df[\"p_from\"].sum()) + e6(df[\"p_to\"].sum())\n",
" Q_total = e6(df[\"q_from\"].sum()) + e6(df[\"q_to\"].sum())\n",
"\n",
" # Ausgabe der Gesamtsummen\n",
" print(\"\\nTotal Power for all Branches\")\n",
" print(\"----------------------------\")\n",
" print(f\"Total Active Power (P_total): {P_total:.2f} MW\")\n",
Expand Down
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ examples/Validation Examples.ipynb
examples/Make Test Dataset.ipynb
examples/Asymmetric Calculation Example.ipynb
examples/Transformer Examples.ipynb
examples/Generic Branch Example.ipynb
```

```{toctree}
Expand Down
Loading