Ultra fast power flow based in Laurent series expansion.
Project description
TensorPowerFlow
What is TensorPowerFlow?
An ultra-fast power flow based on Laurent series expansion. The power flow is intended for applications where massive amounts of power flow computations are required. e.g., electrical load time series, metaheuristics, electrical grid environments for reinforcement learning.
How to install
The package can be installed via pip using:
pip install tensorpowerflow
Example:
Run the load base case as:
from tensorpowerflow import GridTensor
import numpy as np
from time import perf_counter
#%% Solve base case (34 node bus)
network = GridTensor()
solution = network.run_pf()
print(solution["v"])
#%% Solve 10_000 power flows on the 34 node bus case.
network_size = network.nb - 1 # Size of network without slack bus.
active_ns = np.random.normal(50, scale=1, size=(10_000, network_size)) # Power in kW
reactive_ns = active_ns * 0.1 # kVAr
solution_tensor = network.run_pf(active_power=active_ns, reactive_power=reactive_ns)
print(solution_tensor["v"])
#%% Generate random radial network of 100 nodes and a maximum of 1 to 3 branches per node.
network_rnd = GridTensor.generate_from_graph(nodes=100, child=3, plot_graph=True)
solution_rnd = network_rnd.run_pf()
print(solution_rnd["v"])
#%% Solve a tensor power flow. For 10 scenarios, 8_760 time steps (one year - 1 hr res), for the 33 PQ nodes.
# Meaning that the dimensions of the tensor is (10, 8_760, 33)
network = GridTensor(numba=True) # Loads the basic 34 bus node network.
active_ns = np.random.normal(50, # Power in kW
scale=10,
size=(10, 8_760, 33)).round(3) # Assume 1 slack variable
reactive_ns = (active_ns * .1).round(3) # Constant PF of 0.1
start_tensor_dense = perf_counter()
solution = network.run_pf(active_power=active_ns, reactive_power=reactive_ns, algorithm="tensor")
t_tensor_dense = perf_counter() - start_tensor_dense
assert solution["convergence"], "Algorithm did not converge."
assert solution["v"].shape == active_ns.shape
print(f"Time tensor dense: {t_tensor_dense:.3f} sec.")
More examples can be found in the examples folder (under development). Also, you can try the package via jupyter lab clicking in the binder icon:
Reading and citations:
The mathematical formulation of the power flow can be found at:
“A Fixed-Point Current Injection Power Flow for Electric Distribution Systems using Laurent Series.” J.S. Giraldo, O.D. Montoya, P.P. Vergara, F. Milano. Power Systems Computational Conference (PSCC) 2022. link
How to contact us
Any questions, suggestions or collaborations contact Juan S. Giraldo at <jnse@ieee.org>
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file tensorpowerflow-0.0.5.tar.gz
.
File metadata
- Download URL: tensorpowerflow-0.0.5.tar.gz
- Upload date:
- Size: 27.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13f1c0fd1ca8857d4488b557fd76e40b202e831853217641282f627c9b439104 |
|
MD5 | 48999387d64185d75f04485dfed51654 |
|
BLAKE2b-256 | db79b708e6f1f2e9dc0cb3ada954459422cfe6e7a773180e4ac936b46c23a5a2 |
File details
Details for the file tensorpowerflow-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: tensorpowerflow-0.0.5-py3-none-any.whl
- Upload date:
- Size: 30.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f36a11866de68cd63842c7bff56a0e15e9f0da76e538edbcea06b2bbeb0a0e62 |
|
MD5 | 90d78c775539cff6dc88096a1930f986 |
|
BLAKE2b-256 | 48ccc6e62f9bfaf10fb32f6755980ac48007d4904830dcccaf293da634520a44 |