|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Development Environment Setup |
| 6 | + |
| 7 | +**Poetry Environment Activation:** |
| 8 | +```bash |
| 9 | +source $(poetry env info --path)/bin/activate |
| 10 | +``` |
| 11 | + |
| 12 | +**Install Dependencies:** |
| 13 | +```bash |
| 14 | +poetry install |
| 15 | +``` |
| 16 | + |
| 17 | +## Common Development Commands |
| 18 | + |
| 19 | +**Code Quality:** |
| 20 | +```bash |
| 21 | +# Format code with black |
| 22 | +source $(poetry env info --path)/bin/activate && black . |
| 23 | + |
| 24 | +# Run linter |
| 25 | +source $(poetry env info --path)/bin/activate && flake8 . |
| 26 | + |
| 27 | +# Run all pre-commit hooks |
| 28 | +pre-commit run --all-files |
| 29 | +``` |
| 30 | + |
| 31 | +**Testing:** |
| 32 | +```bash |
| 33 | +# Run all tests |
| 34 | +source $(poetry env info --path)/bin/activate && python -m pytest |
| 35 | + |
| 36 | +# Run specific test file |
| 37 | +source $(poetry env info --path)/bin/activate && python -m pytest tests/path/to/test_file.py |
| 38 | + |
| 39 | +# Run tests with specific pattern |
| 40 | +source $(poetry env info --path)/bin/activate && python -m pytest -k "test_pattern" |
| 41 | +``` |
| 42 | + |
| 43 | +**Dependency Management:** |
| 44 | +```bash |
| 45 | +# Check for unused dependencies |
| 46 | +source $(poetry env info --path)/bin/activate && deptry . |
| 47 | +``` |
| 48 | + |
| 49 | +## Code Architecture |
| 50 | + |
| 51 | +**Core Components:** |
| 52 | + |
| 53 | +1. **Models Package** (`pypsdm/models/`): |
| 54 | + - `input/`: Input data models for grid components and participants |
| 55 | + - `result/`: Result data models for simulation outputs |
| 56 | + - `ts/`: Time series data types and utilities |
| 57 | + - `gwr.py`: Main `GridWithResults` class combining input and result data |
| 58 | + |
| 59 | +2. **Key Classes:** |
| 60 | + - `GridWithResults`: Main facade combining grid model and simulation results |
| 61 | + - `GridContainer`: Contains raw grid elements and system participants |
| 62 | + - `GridResultContainer`: Contains simulation results for grid and participants |
| 63 | + - `SystemParticipantsContainer`: Manages participants (loads, PVs, storage, etc.) |
| 64 | + |
| 65 | +3. **Data Flow:** |
| 66 | + - CSV files → Container classes → Analysis/Plotting |
| 67 | + - Input models define grid structure and participant parameters |
| 68 | + - Result models contain time series simulation outputs |
| 69 | + - GridWithResults provides unified interface for analysis |
| 70 | + |
| 71 | +**Supported Grid Elements:** |
| 72 | +- Nodes, lines, transformers, switches |
| 73 | +- Participants: loads, PVs, storage, EVs, heat pumps, biomass plants, wind energy converters |
| 74 | +- Time series data with complex power values |
| 75 | + |
| 76 | +**Key Features:** |
| 77 | +- CSV-based data I/O with configurable delimiters |
| 78 | +- Plotting utilities for grid visualization and result analysis |
| 79 | +- Pandapower conversion capabilities |
| 80 | +- Database integration for weather and geographic data |
| 81 | +- Numba-optimized processing for performance |
| 82 | + |
| 83 | +## Code Style Configuration |
| 84 | + |
| 85 | +- **Black**: Line length 88 characters |
| 86 | +- **Flake8**: Configured in `setup.cfg` with ignore rules for E203, E501, W503 |
| 87 | +- **isort**: Black-compatible profile |
| 88 | +- **Pre-commit hooks**: black, flake8, isort |
| 89 | + |
| 90 | +## Testing Structure |
| 91 | + |
| 92 | +- Test resources located in `tests/resources/` |
| 93 | +- Fixtures defined in `tests/conftest.py` for common test data paths |
| 94 | +- Test data includes SimBench grids and VN_SIMONA results |
| 95 | +- Tests organized by module structure matching `pypsdm/` |
| 96 | + |
| 97 | +## Development Notes |
| 98 | + |
| 99 | +- Uses Poetry for dependency management |
| 100 | +- Python 3.11+ required |
| 101 | +- Dataclasses with frozen=True for immutable data structures |
| 102 | +- Type hints throughout codebase |
| 103 | +- Loguru for logging |
| 104 | +- Supports both input-only and input+results workflows |
0 commit comments