Skip to main content
Pre-release

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 WireSpacingInfo is present, export it as native GridLAB-D line_spacing + overhead_line_conductor objects. See cimhub_core/development/CONDUCTOR_GEOMETRY_ANTI_PATTERNS.md.
  • Python complex literals (+0.79+0.43j) are not valid GLM syntax — the writer uses explicit r / x fields.
  • Phase lookups must traverse from ACLineSegment.ACLineSegmentPhases, not from WireSpacingInfo.ACLineSegment[0] (that list can be empty).

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cimhub_gridlabd-2.0.0a1.tar.gz (387.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cimhub_gridlabd-2.0.0a1-py3-none-any.whl (428.9 kB view details)

Uploaded Python 3

File details

Details for the file cimhub_gridlabd-2.0.0a1.tar.gz.

File metadata

  • Download URL: cimhub_gridlabd-2.0.0a1.tar.gz
  • Upload date:
  • Size: 387.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cimhub_gridlabd-2.0.0a1.tar.gz
Algorithm Hash digest
SHA256 f567ae8f6d6d119b342ecff398984f27575979b454fcab26f12ac07284410a31
MD5 5e89e25200c0da4693d970eef648bac2
BLAKE2b-256 fb28ef11a8f262db76fc04fdef79606cb6e8227a1388b1027e1bb190b9b33abd

See more details on using hashes here.

Provenance

The following attestation bundles were made for cimhub_gridlabd-2.0.0a1.tar.gz:

Publisher: publish-cimhub-gridlabd.yml on PNNL-CIM-Tools/CIMHub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cimhub_gridlabd-2.0.0a1-py3-none-any.whl.

File metadata

File hashes

Hashes for cimhub_gridlabd-2.0.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 80513945e6dc89fcacb7b89979ba8a530c604b2a1d6ff086df3df096b8ec577e
MD5 c1e443ec5a30f4bc7877d09ecee98ecf
BLAKE2b-256 1f8d24b766adc74c76e2abcb73671a706e8f41f04d17fb716f1a550554c89b75

See more details on using hashes here.

Provenance

The following attestation bundles were made for cimhub_gridlabd-2.0.0a1-py3-none-any.whl:

Publisher: publish-cimhub-gridlabd.yml on PNNL-CIM-Tools/CIMHub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page