This release is a pre-release and may not be stable for production use.
cimhub_gridlabd
Bidirectional converter between GridLAB-D (GLM) and CIM (IEC 61968/61970) using the cimhub_2026 profile.
Usage
GLM to CIM (Import)
import os
os.environ['CIMG_USE_UNITS'] = 'TRUE'
os.environ['CIMG_CIM_PROFILE'] = 'cimhub_2026'
from cimhub_gridlabd.importer.glm_to_cim import glm_to_cim
feeder = glm_to_cim("/path/to/IEEE13.glm")
CIM to GLM (Export)
Export is two steps: build the GLM model, then write it.
from cimhub_gridlabd.exporter.cim_to_glm import GlmExporter
from cimhub_gridlabd.exporter.glm_text_writer import GlmTextWriter
glm_model = GlmExporter().to_model(feeder)
GlmTextWriter().write(glm_model, "/path/to/IEEE13.glm")
to_model returns an in-memory GraphModel of GLM dataclasses, so you can
inspect or edit the model before it is serialized.
JSON variant
Swap in the GLM-JSON writer (one object per JSON entry, grouped by class):
from cimhub_gridlabd.exporter.cim_to_glm import GlmExporter
from cimhub_gridlabd.exporter.glm_writer import GlmJsonWriter
glm_model = GlmExporter().to_model(feeder)
GlmJsonWriter().write(glm_model, "/path/to/IEEE13.json")
Or use the one-line convenience wrapper:
from cimhub_gridlabd.exporter.cim_to_glm import cim_to_glm_json
cim_to_glm_json(feeder, "/path/to/IEEE13.json")
Architecture
The package follows the standard CIMHub four-layer pipeline:
LinkML YAML → glm_schema.py → GraphModel → GlmReader / GlmWriter
↕
GlmImporter / GlmExporter
The writer is annotation-driven: LinkML slot annotations (native_name, glm_unit, etc.) control how each CIM field maps to a GLM attribute without hard-coded per-class logic. See GLM_LINKML_ARCHITECTURE.md for the full design.
Equipment Coverage
| Element | Import | Export |
|---|---|---|
| Overhead lines (geometry) | ✓ | ✓ |
| Underground cables | ✓ | ✓ |
| Transformers | ✓ | ✓ |
| Regulators | ✓ | ✓ |
| Capacitor banks | ✓ | ✓ |
| Loads | ✓ | ✓ |
| Switches / reclosers / fuses | ✓ | ✓ |
| DER (PV, battery) | partial | partial |
Running Tests
uv run pytest cimhub_gridlabd/tests/ -v
Notes
- Never substitute a computed impedance matrix for conductor geometry. When
WireSpacingInfois present, export it as native GridLAB-Dline_spacing+overhead_line_conductorobjects. Seecimhub_core/development/CONDUCTOR_GEOMETRY_ANTI_PATTERNS.md. - Python complex literals (
+0.79+0.43j) are not valid GLM syntax — the writer uses explicitr/xfields. - Phase lookups must traverse from
ACLineSegment.ACLineSegmentPhases, not fromWireSpacingInfo.ACLineSegment[0](that list can be empty).
Metadata
Release files for cimhub-gridlabd 2.0.0a1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cimhub_gridlabd-2.0.0a1.tar.gz | 387.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cimhub_gridlabd-2.0.0a1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 816.1 kB
Release files / cimhub_gridlabd-2.0.0a1.tar.gz
| Download URL | cimhub_gridlabd-2.0.0a1.tar.gz |
|---|---|
| Size | 387.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f567ae8f6d6d119b342ecff398984f27575979b454fcab26f12ac07284410a31
|
|
BLAKE2b-256 checksum How to use checksums |
fb28ef11a8f262db76fc04fdef79606cb6e8227a1388b1027e1bb190b9b33abd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 20, 2026.
Transparency logRelease files / cimhub_gridlabd-2.0.0a1-py3-none-any.whl
| Download URL | cimhub_gridlabd-2.0.0a1-py3-none-any.whl |
|---|---|
| Size | 428.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
80513945e6dc89fcacb7b89979ba8a530c604b2a1d6ff086df3df096b8ec577e
|
|
BLAKE2b-256 checksum How to use checksums |
1f8d24b766adc74c76e2abcb73671a706e8f41f04d17fb716f1a550554c89b75
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 20, 2026.
Transparency log