Core data models and I/O for the psforge power system analysis ecosystem. LLM-friendly design for AI-assisted analysis.
Project description
psforge-grid
Hub data model for the psforge power system analysis ecosystem
Core data models and I/O for power system analysis with LLM-friendly design.
Quick Start
pip install psforge-grid
from psforge_grid import System
# Load a PSS/E RAW file
system = System.from_raw("ieee14.raw")
# Explore the system
print(f"Buses: {len(system.buses)}, Branches: {len(system.branches)}")
# Get LLM-friendly summary
print(system.to_summary())
# Or use the CLI
psforge-grid info ieee14.raw
psforge-grid show ieee14.raw buses -f json
Why psforge-grid?
| Feature | psforge-grid | Others |
|---|---|---|
| LLM-friendly output | Built-in JSON/summary formats | Manual formatting |
| Educational design | Rich docstrings, clear naming | Varies |
| Type hints | Complete type annotations | Often missing |
| CLI included | Yes, with multiple output formats | Usually separate |
| PSS/E RAW support | v33/v34 core sections | Varies |
Overview
psforge-grid serves as the Hub of the psforge ecosystem, providing:
- Common data classes (
System,Bus,Branch,Generator,Load,Shunt) - PSS/E RAW file parser (v33/v34 partial support)
- Shared utilities for power system analysis
LLM Affinity Design
"Pickaxe in the Gold Rush" - psforge is designed for seamless LLM integration.
psforge-grid implements LLM-friendly data structures and CLI:
| Feature | Description |
|---|---|
| Explicit Units | Field names include units (voltage_pu, power_mw) |
| Semantic Status | Enum-based status annotations (VoltageStatus.LOW) |
| Self-Documenting | Rich docstrings explaining physical meaning |
| to_description() | Human/LLM-readable output methods |
# Example: LLM-friendly bus description
bus = system.get_bus(14)
print(bus.to_description())
# Output: "Bus 14 (LOAD_BUS): 13.8 kV, PQ type"
CLI for LLM Integration
psforge-grid includes a CLI designed for LLM-friendly output:
# System summary in different formats
psforge-grid info ieee14.raw # Table format
psforge-grid info ieee14.raw -f json # JSON for API/LLM
psforge-grid info ieee14.raw -f summary # Compact for tokens
# Display element details
psforge-grid show ieee14.raw buses
psforge-grid show ieee14.raw branches -f json
# Validate system data
psforge-grid validate ieee14.raw
psforge-grid validate ieee14.raw --strict
Output Formats:
table: Human-readable tables (default)json: Structured JSON for LLM/API processingsummary: Compact text for token-efficient LLM usagecsv: Comma-separated values for data analysis
See CLAUDE.md for detailed AI development guidelines.
PSS/E RAW Format Support
Current Status
The parser supports core power flow data required for basic AC power flow analysis:
| Section | v33 | v34 | Notes |
|---|---|---|---|
| Case Identification | Yes | Yes | Base MVA, system info |
| Bus Data | Yes | Yes | All bus types (PQ, PV, Slack, Isolated) |
| Load Data | Yes | Yes | Constant power loads |
| Fixed Shunt Data | Yes | Yes | Capacitors and reactors |
| Generator Data | Yes | Yes | P, Q, voltage setpoint, Q limits |
| Branch Data | Yes | Yes | Transmission lines |
| Transformer Data | Yes | Yes | Two-winding transformers only |
Not Yet Supported
The following sections are parsed but ignored (data is skipped):
- Area Data, Zone Data, Owner Data
- Two-Terminal DC Data, Multi-Terminal DC Data
- VSC DC Line Data, FACTS Device Data
- Switched Shunt Data (use Fixed Shunt instead)
- Multi-Section Line Data, Impedance Correction Data
- GNE Data, Induction Machine Data, Substation Data
- Three-winding Transformers
Test Data Sources
Parser has been validated with IEEE test cases from multiple sources:
- IEEE 9-bus (v34): GitHub - todstewart1001
- IEEE 14-bus (v33): GitHub - ITI/models
- IEEE 118-bus (v33): GitHub - powsybl
Future Plans
- Phase 2: Three-winding transformer support
- Phase 3: Switched shunt data support
- Future: HVDC, FACTS device support (as needed)
Installation
# Install the package
pip install psforge-grid
# Or install from source
pip install -e .
Development Setup
Prerequisites
- Python 3.9+
- uv (recommended) or pip
Install Development Dependencies
# Using uv (recommended)
uv pip install -e ".[dev]"
# Or using pip
pip install -e ".[dev]"
Setup Pre-commit Hooks
Pre-commit hooks automatically run ruff and mypy checks before each commit.
Option 1: Global Install with pipx (Recommended)
Using pipx for global installation is recommended, especially when using git worktree for parallel development. This ensures pre-commit is available across all worktrees without additional setup.
# Install pipx if not already installed
brew install pipx # macOS
# or: pip install --user pipx
# Install pre-commit globally
pipx install pre-commit
# Install hooks (only needed once per repository)
pre-commit install
# Run hooks manually on all files
pre-commit run --all-files
Why pipx?
- Works across all git worktrees without per-worktree setup
- Isolated environment prevents dependency conflicts
- Single installation, works everywhere
Option 2: Local Install in Virtual Environment
# Install pre-commit in your virtual environment
pip install pre-commit
# Install hooks
pre-commit install
# Run hooks manually on all files
pre-commit run --all-files
Note: CI runs ruff and mypy checks via GitHub Actions (
.github/workflows/test.yml), so code quality is enforced on push/PR even if local hooks are skipped.
Manual Code Quality Checks
# Lint with ruff
ruff check src/ tests/
# Format with ruff
ruff format src/ tests/
# Type check with mypy
mypy src/
Run Tests
pytest tests/ -v
Editor Setup (VSCode/Cursor)
This project includes .vscode/ configuration for seamless development:
- Format on Save: Automatically formats code with ruff
- Organize Imports: Automatically sorts imports
- Type Checking: Mypy extension provides real-time type checking
Recommended Extensions:
charliermarsh.ruff- Ruff linter and formatterms-python.mypy-type-checker- Mypy type checkerms-python.python- Python language support
Related Projects
psforge is a modular power system analysis ecosystem:
| Package | Description | Status |
|---|---|---|
| psforge-grid (this) | Core data models and I/O (Hub) | Active |
| psforge-flow | AC power flow calculation | Active |
| psforge-stability | Transient stability analysis | Planned |
| psforge-schedule | Unit commitment optimization | Planned |
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Run tests (
pytest tests/) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
See CLAUDE.md for AI development guidelines.
License
MIT License - see LICENSE for details.
Developed by Manabe Lab LLC
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file psforge_grid-0.2.1.tar.gz.
File metadata
- Download URL: psforge_grid-0.2.1.tar.gz
- Upload date:
- Size: 49.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12cb17f751c4ab7ea82a111b6c81a32dc99102924db366c84189f3e181d1f2d5
|
|
| MD5 |
60404c86a5bbf271041971c19945dfff
|
|
| BLAKE2b-256 |
159bc8abe688cdc5ba99188bbe58d4177e20ccfdb83d0f7cf16adf6b5bd15cab
|
Provenance
The following attestation bundles were made for psforge_grid-0.2.1.tar.gz:
Publisher:
publish.yml on manabelab/psforge-grid
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
psforge_grid-0.2.1.tar.gz -
Subject digest:
12cb17f751c4ab7ea82a111b6c81a32dc99102924db366c84189f3e181d1f2d5 - Sigstore transparency entry: 953059353
- Sigstore integration time:
-
Permalink:
manabelab/psforge-grid@27b39a225482a7f9de6b7104b65f977792b6bb78 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/manabelab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@27b39a225482a7f9de6b7104b65f977792b6bb78 -
Trigger Event:
release
-
Statement type:
File details
Details for the file psforge_grid-0.2.1-py3-none-any.whl.
File metadata
- Download URL: psforge_grid-0.2.1-py3-none-any.whl
- Upload date:
- Size: 48.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b484a6acfc399facf4c6da1483c23367f08e74acea10136b5f3e87efea41f36
|
|
| MD5 |
d2157cb4021aa69dc928e3152cd8cf3b
|
|
| BLAKE2b-256 |
f9c74de4178520597d406c8672ccc797b714149bb1896e07f6a8560b5c1b63ff
|
Provenance
The following attestation bundles were made for psforge_grid-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on manabelab/psforge-grid
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
psforge_grid-0.2.1-py3-none-any.whl -
Subject digest:
5b484a6acfc399facf4c6da1483c23367f08e74acea10136b5f3e87efea41f36 - Sigstore transparency entry: 953059366
- Sigstore integration time:
-
Permalink:
manabelab/psforge-grid@27b39a225482a7f9de6b7104b65f977792b6bb78 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/manabelab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@27b39a225482a7f9de6b7104b65f977792b6bb78 -
Trigger Event:
release
-
Statement type: