{"id":16517947,"url":"https://github.com/mzy2240/fastse","last_synced_at":"2025-10-28T07:30:17.911Z","repository":{"id":37294833,"uuid":"504964382","full_name":"mzy2240/fastSE","owner":"mzy2240","description":"A collection of power system analysis tools. Optimized for large-scale grid.","archived":false,"fork":false,"pushed_at":"2022-09-15T17:01:35.000Z","size":92,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-09-27T09:05:58.694Z","etag":null,"topics":["aot","hpc","jit","power-flow","powersystem","sparse-matrix","state-estimation"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mzy2240.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-18T22:37:36.000Z","updated_at":"2023-11-11T00:22:44.000Z","dependencies_parsed_at":"2022-08-08T19:31:06.386Z","dependency_job_id":null,"html_url":"https://github.com/mzy2240/fastSE","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mzy2240%2FfastSE","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mzy2240%2FfastSE/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mzy2240%2FfastSE/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mzy2240%2FfastSE/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mzy2240","download_url":"https://codeload.github.com/mzy2240/fastSE/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219860044,"owners_count":16556029,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aot","hpc","jit","power-flow","powersystem","sparse-matrix","state-estimation"],"created_at":"2024-10-11T16:34:21.405Z","updated_at":"2025-10-28T07:30:17.503Z","avatar_url":"https://github.com/mzy2240.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚀FastSE\n[![PyPI pyversions](https://img.shields.io/pypi/pyversions/fastSE.svg)](https://pypi.python.org/pypi/fastSE/)\n[![PyPI version fury.io](https://badge.fury.io/py/fastSE.svg)](https://pypi.python.org/pypi/fastSE/)\n[![Downloads](https://pepy.tech/badge/fastse)](https://pepy.tech/project/fastse)\n[![PyPI license](https://img.shields.io/pypi/l/fastSE.svg)](https://pypi.python.org/pypi/fastSE/)\n\n\n\n\u003e A collection of power system computation modules\n\nsparse matrix + aot/jit + klu + custom improved ordering + python\n= efficiency in computation and development!\n\n# 🌟Features\n\n* ⚡Jitted and KLU-powered [state estimation](https://github.com/mzy2240/fastSE/blob/master/fastse/se.py)\n* ⚡Jitted and KLU-powered [power flow](https://github.com/mzy2240/fastSE/blob/master/fastse/pf.py)\n* ⚡Jitted and KLU-powered [continuation power flow](https://github.com/mzy2240/fastSE/blob/master/fastse/cpf.py)\n* ⚡Jitted and KLU-powered [temperature-dependent power flow](https://github.com/mzy2240/fastSE/blob/master/fastse/tdpf.py)\n* :crab:Rust-powered network routing for operational resilience\n\n# Installation\n\nTo install, simply run `pip install fastSE` in your command prompt.\n\n# How to use\n\nHere is one simple example. `solve_se_lm` is a high-level function which\ncomputes derivatives, assemble them as sparse matrix and then calculate the \nestimates using sparse matrix solver. All the low-level functions could also\nbe imported and used individually.\n\n```python\nfrom fastse import StateEstimator, StateEstimationInput\nfrom fastse import bdd_validation\nfrom scipy.sparse import csr_matrix\nimport numpy as np\n\nimport time\n# A 5 bus example from Prof. Overbye's textbook\n# node impedance\nYbus = np.array([[3.729 - 49.720j, 0.000 + 0.000j, 0.000 + 0.000j,\n        0.000 + 0.000j, -3.729 + 49.720j],\n       [0.000 + 0.000j, 2.678 - 28.459j, 0.000 + 0.000j,\n        -0.893 + 9.920j, -1.786 + 19.839j],\n       [0.000 + 0.000j, 0.000 + 0.000j, 7.458 - 99.441j,\n        -7.458 + 99.441j, 0.000 + 0.000j],\n       [0.000 + 0.000j, -0.893 + 9.920j, -7.458 + 99.441j,\n        11.922 - 147.959j, -3.571 + 39.679j],\n       [-3.729 + 49.720j, -1.786 + 19.839j, 0.000 + 0.000j,\n        -3.571 + 39.679j, 9.086 - 108.578j]])\nYbus = csr_matrix(Ybus)\n\n# branch impedance\nYf = np.array([[ 3.729-49.720j,  0.000 +0.000j,  0.000 +0.000j,  0.000 +0.000j,\n    -3.729+49.720j],\n   [ 0.000 +0.000j, -0.893 +9.920j,  0.000 +0.000j,  0.893 -9.060j,\n     0.000 +0.000j],\n   [ 0.000 +0.000j, -1.786+19.839j,  0.000 +0.000j,  0.000 +0.000j,\n     1.786-19.399j],\n   [ 0.000 +0.000j,  0.000 +0.000j,  7.458-99.441j, -7.458+99.441j,\n     0.000 +0.000j],\n   [ 0.000 +0.000j,  0.000 +0.000j,  0.000 +0.000j, -3.571+39.679j,\n     3.571-39.459j]])\nYf = csr_matrix(Yf)\n\nYt = np.array([[-3.729+49.720j,  0.000 +0.000j,  0.000 +0.000j,  0.000 +0.000j,\n     3.729-49.720j],\n   [ 0.000 +0.000j,  0.893 -9.060j,  0.000 +0.000j, -0.893 +9.920j,\n     0.000 +0.000j],\n   [ 0.000 +0.000j,  1.786-19.399j,  0.000 +0.000j,  0.000 +0.000j,\n    -1.786+19.839j],\n   [ 0.000 +0.000j,  0.000 +0.000j, -7.458+99.441j,  7.458-99.441j,\n     0.000 +0.000j],\n   [ 0.000 +0.000j,  0.000 +0.000j,  0.000 +0.000j,  3.571-39.459j,\n    -3.571+39.679j]])\nYt = csr_matrix(Yt)\n\n# branch from and to bus\nf = np.array([0, 3, 4, 2, 4])\nt = np.array([4, 1, 1, 3, 3])\n\n# slack, pv and pq buses\nslack = np.array([0])  # The slack bus does not have to be the 0-indexed bus\npq = np.array([1, 3, 4])\npv = np.array([2])\n\n# measurements\nse_input = StateEstimationInput()\n\nse_input.p_inj = np.array([ 3.948e+00, -8.000e+00,  4.400e+00, -6.507e-06, -1.407e-05])\nse_input.p_inj_idx = np.arange(len(se_input.p_inj))\nse_input.p_inj_weight = np.full(len(se_input.p_inj), 0.01)\n\nse_input.q_inj = np.array([ 1.143e+00, -2.800e+00,  2.975e+00,  6.242e-07,  1.957e-06])\nse_input.q_inj_idx = np.arange(len(se_input.q_inj))\nse_input.q_inj_weight = np.full(len(se_input.q_inj), 0.01)\n\nse_input.vm_m = np.array([0.834, 1.019, 0.974])\nse_input.vm_m_idx = pq\nse_input.vm_m_weight = np.full(len(se_input.vm_m), 0.01)\n\n# First time will be slow due to compilation\nstart = time.time()\nestimator = StateEstimator()\nv_sol, err, converged, results = estimator.solve_se_lm(se_input, Ybus, Yf, Yt, f, t, slack, pq, pv, flat=True)\nprint(\"compilation + execution time:\", time.time() - start)\nbdd_validation(results, m=len(se_input.measurements), n=Ybus.shape[0] + len(pq) + len(pv))\n\n# But then it will be very performant\nstart = time.time()\nv_sol, err, converged, results = estimator.solve_se_lm(se_input, Ybus, Yf, Yt, f, t, slack, pq, pv, flat=True)\nprint(\"Execution time:\", time.time() - start)\n\n# Start from previous solution (set flat = False)\nstart = time.time()\nv_sol, err, converged, results = estimator.solve_se_lm(se_input, Ybus, Yf, Yt, f, t, slack, pq, pv, flat=False)\nprint(\"Execution time:\", time.time() - start)\n\n# False data injection\nse_input.vm_m[1] -= 0.025\nse_input.vm_m[2] += 0.025\nv_sol, err, converged, results = estimator.solve_se_lm(se_input, Ybus, Yf, Yt, f, t, slack, pq, pv)\nprint(\"-------------After False Data Injection-------------\")\nbdd_validation(results, m=len(se_input.measurements), n=Ybus.shape[0] + len(pq) + len(pv))\n\n```\n\n# References\n\n### Temperature Dependent Power Flow (Temperature Dependent Load Flow)\n\nS. Frank, J. Sexauer and S. Mohagheghi, \"Temperature-Dependent Power Flow,\" in IEEE Transactions on Power Systems, vol. 28, no. 4, pp. 4007-4018, Nov. 2013, doi: 10.1109/TPWRS.2013.2266409.\n\nRahman, Mahbubur et al. “Power handling capabilities of transmission systems using a temperature-dependent power flow.” Electric Power Systems Research (2019): n. pag.\n\n# Acknowledge\n\nThis work was supported by the U.S. Department of Energy (DOE) under award DE-OE0000895 and the Sandia National Laboratories’ directed R\u0026D project #222444.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmzy2240%2Ffastse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmzy2240%2Ffastse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmzy2240%2Ffastse/lists"}