Skip to content

cim18v17 → GridLAB-D export spec

Plan and decisions: .development/GLM_REWRITE_PLAN.md §8 (X1-X9 and §8.5, the user's 2026-11-21). The exporter reads values only through the core getters (skill export-getters) and asks each for the GLM slot's own unit (exporter/units.py, X8). The GlmModel it returns has the shape GlmReader.read_all() returns, so GlmWriter's deck reads back through the reader and the importer, and GridLAB-D 6.0 solves it.

Layout

cimhub_gridlabd/src/cimhub_gridlabd/
    glm_writer.py             GlmWriter: clock, #set, modules, class blocks, then objects in WRITE_ORDER; values a+bj,
                              TRUE/FALSE, "text", an unset slot's expression as is; each player's tape beside the deck
    exporter/
        cim_to_glm.py         GlmExporter(time_points=None).to_model(network, *, name_source, switch_state), EXPORT_ORDER,
                              cim_to_glm(network, destination, *, time_points=None, **opts); raises on equipment no
                              module exports
        naming.py             Names: the shared name switch (X1) + glm_safe_name, one namespace per deck
        units.py              glm_unit(class, slot): the schema's unit as a pint unit; from_percent
        buses.py              node / triplex_node / substation, each bus's system and nominal_voltage
        line.py, line_catalog.py   lines and the conductors, spacings and configurations they name
        switch.py             switch, fuse, recloser, sectionalizer
        series_reactor.py     series_reactor (X28)
        transformer.py        transformer + transformer_configuration: native, centre tap, wye-wye, star split, banks
        regulator.py          regulator + regulator_configuration
        player.py             player: a ConformLoadSchedule with points (X29)
        load.py, capacitor.py, inverter.py

Each module has CIM_CLASSES, SLOTS ({GLM class: {slot: Slot}}, cimhub_core.export_slots) and export(context) -> list[record]. test_export_framework.py checks that SLOTS names every schema slot and that the tables at the end of this file are the generated ones.

X0: framework, writer, buses and the swing

  • Deck header: one power flow, a clock that starts and stops at one instant; #set relax_naming_rules=1; module powerflow { solver_method NR; nominal_frequency f; line_capacitance TRUE; }, f the network's base frequency (line_capacitance: CIM's line b is part of the model, and GridLAB-D ignores every c without it); module generators when the deck holds DER.
  • Names (X1): cimhub_core.names.export_name (name, mrid, uri; default mrid), glm_safe_name (a . is GridLAB-D's object.property, : its class:id; whitespace, quotes, ;, braces and $ end a token), one namespace, a collision raises. GLM-origin models round-trip under name_source="name".
  • Buses: a ConnectivityNode is a node, a triplex_node on a split-phase bus, the swing's a substation. Its system is read per voltage zone (cimtopology.core.Topology.voltage_zones): s1/s2 split phase (the service letter from its centre taps' primary); a polyphase EnergySource or transformer end, or one-phase ends on different phases (a bank) three phase; a one-phase EnergySource, or one-phase ends on one phase, single phase. nominal_voltage is the BaseVoltage over √3, as is, or over 2. Phases: every terminal's A, B, C, then N (S for a triplex bus).
  • The swing (X6): one EnergySource, bustype SWING, nominal_voltage its nominalVoltage, over √3 on a three-phase system and as is on a one-phase one (the importer's line_voltage inverted, so the deck's own figure comes back), positive_sequence_voltage voltageMagnitude at voltageAngle on the same rule. GridLAB-D's substation needs all three phases, so a one-phase swing is a node with bustype SWING and voltage_A instead (the form the importer reads), and a graph with a BasePower then raises: a node has no base_power. A substation's base_power is the graph's BasePower when it holds one (network.base_power's 100 MVA default is not CIM's). GLM's swing is ideal: the source impedance is not written. Two EnergySources raise (NR takes one).

X1: lines and switches

  • A line is geometry when its WireConfiguration names a WireSpacing (get_line_geometry; skill conductor-geometry), whatever else it has. The WireConfiguration is the equivalence route: an XYSpacing and a ConductorDistanceSpacing may both lead to one configuration, and it may also carry the PerLengthImpedance its geometry equals. A geometry line is a line_configuration with conductor_X the wire at phase X's sequence number and a line_spacing with the distances and heights the spacing holds (get_stored_distances; a pair or height left out is GridLAB-D's 0). No impedance is computed from geometry. A split-phase line is a triplex_line whose configuration's diameter and insulation_thickness come from its spacing (S2-8 inverted). A geometry line with a cable is an underground_line.
  • Otherwise its code (get_line_code: its own PerLengthImpedance, else its WireConfiguration's, a template LineCode; both set and different raise) is a matrix configuration by phase letter, a neutral Kron-reduced out, b as c = c_from_b at the base frequency (b unset: c unset, GridLAB-D's 0); a sequence code is expanded by the getter. A triplex matrix's b is not written, logged once per configuration (X27): GridLAB-D 6.0's triplex_line has no shunt admittance (triplex_line.cpp:315 fills only the series matrix), so no triplex_line_configuration slot holds it. IEEE 8500's triplex codes (3.0 / -2.4 nF per kft) carry about 0.1 VAr per kft at 240 V. The importer reads the triplex z11, z12, z21, z22 back as an s1, s2 PerLengthPhaseImpedance (S2-8).
  • A template used on different phases is one GLM object per use, <template>_<letters>.
  • Conductors: rAC50 (the GLM importer's), else rAC25 (the DSS importer's). A bare wire buried in an underground configuration gets outer_diameter = 1.2 × its diameter (the Java exporter's rule; GridLAB-D needs one). A tape shield's shield_gmr = diameterOverScreen / 2 and shield_resistance = 18.826 / (d_s[in] × T[mil]) Ω/mile (Kersting eq. 4.89, the Java exporter's): GridLAB-D tells a tape-shield cable by shield_gmr > 0.
  • Switches: Fuse fuse (current_limit = ratedCurrent), Recloser recloser, Sectionaliser sectionalizer, every other Switch switch; status from switch_state (actual: open, normal: normalOpen).
  • Ratings: each link's own normal and emergency limits on its phases (D9); a triplex line's on its service letter, which GridLAB-D and the importer read.
  • Series reactors (X28): a SeriesCompensator is a series_reactor on its A, B, C, phase_X_impedance = r + jx (ohm) on each, its ratings a link's. GridLAB-D's reactor has no coupling between phases (series_reactor.cpp:105), so r0/x0 other than r/x raise (the DSS exporter's rule), as does a varistor. The importer's S7 inverted.

X2: transformers and regulators

Per unit (get_transformer_units), the model in pu on winding 1's ratedS:

form written as
Y/Yn/I to Y/Yn/I on one phase set WYE_WYE (one coil SINGLE_PHASE)
D-D on three phases DELTA_DELTA
D-Yn on three phases, phaseShift unset or -30 (Dyn1) DELTA_GWYE
three windings on s1, s2, N SINGLE_PHASE_CENTER_TAPPED, the star whole (impedance, impedance1, impedance2)
any other two windings (X3, the user's rule) WYE_WYE on both windings' phases, logged
three windings, not a centre tap (X4, the user's rule) three legs to a 1 kV star bus <unit>_star; a D leg DELTA_GWYE, else WYE_WYE
single-phase cans with a phase-to-phase coil on the same buses (the user's rule) one bank, then the rows above
one PowerTransformer's lugged cans under a TransformerBankConfiguration (the importer's bank, S3b-9) one WYE_WYE, powerX_rating each can's, named by the bank configuration
  • GridLAB-D's base is secondary_voltage²/power_rating as written: polyphase units line to line on their whole kVA, a coil on its own; a two-phase wye's coil base is n/3 of GridLAB-D's. A bank's cans all get GridLAB-D's one impedance in the same ohms, so each can's own pu × S_total / (3 S_can) (the importer's k inverted) must agree.
  • R ≤ 0 or X ≤ 0 is written at 1e-6 pu and logged (§8.5 Q2); a star's middle branch is often negative.
  • An LTC is folded into its winding's voltage at the actual step; its control is not written (X5).
  • Regulators: one per VoltageRegulator (GridLAB-D takes one-phase regulators side by side). Units the GLM importer split (<base>_<phase> on the same buses, S3c) are <base> again. A delta bank (coils between phases) is WYE_WYE, each coil's tap on its own phase: GridLAB-D 6.0 solves no delta regulator under NR. Type B on a construction typeB, else A (CIM's 1 + step × increment). Control MANUAL when disabled, else LINE_DROP_COMP or OUTPUT_VOLTAGE; a disabled control may have no target (core getter change, 2026-11-21). The compensator settings are written wherever CIM holds a line drop (GridLAB-D reads them on LINE_DROP_COMP only, the importer on any Control). Several units are control_level INDIVIDUAL; one VoltageRegulator alone (a gang on ABC, or one phase not named as the importer's split) is BANK, sensing PT_phase/CT_phase = the control's monitored phase (its first phase under MANUAL), which GridLAB-D and the importer read as one unit (GLM-7, S6).

X3: loads and capacitors

  • A load per EnergyConsumer (a ConformLoad or NonConformLoad too, X29), parented to its bus, in GLM's base_power form per phase (each ZIP part's |S|, fraction and power factor, negative when its Q is). Delta: A, B, C are the branches AB, BC, CA (as cimtables' branch children). A voltage-exponent model with exponents 0, 1 or 2 is constant power, current or impedance; another raises. On a split-phase bus a wye consumer is the legs _1/_2, a delta one the 240 V part _12; the importer's <base>_12 consumer is its base's _12 again (S4a-6).
  • A capacitor per LinearShuntCompensator: capacitor_X at nomU with every section in, switchX from the actual sections, VOLT from an enabled voltage control (the target ± half the deadband, pt_phase the monitored phases, else the unit's own: a BANK capacitor senses one phase). A control of another mode is MANUAL at the actual state, logged. The importer's per-phase units <base>_<phase> are <base> again (S4a-8) when one of them has a voltage control, as the importer splits only an automatic capacitor; a one-phase unit with none keeps its name (cap_B).

X29: load players

GLM_REWRITE_PLAN.md §8.9, the importer's S8 inverted; the points are the caller's time_points (GlmExporter(time_points), the RegularTimePoint table of cimhub_core.time_points).

  • A ConformLoadSchedule with points is a player named after its group, its file <name>.player beside the deck (written by GlmWriter), read through module tape; and class player { double value; }. Rows: the first at startTime in GMT (GridLAB-D reads GMT under any clock zone, timestamp.cpp:595), each later one +<step>s; a step that is not whole seconds, a gap in the sequence numbers, or a value2 other than value1 raise (a GLM base scales p and q together).
  • Each ConformLoad of that group writes its bases as <player>.value*<base> (the expression the reader keeps); a merged 240 V part must follow the same player.
  • The clock's one instant is the earliest player start, so each base is K times the first point; a later stoptime plays the schedule.
  • Written static, their groups named in one warning: a ConformLoad whose group has no schedule (the Java exports' ieeezipload, which their run file defines; writing the reference would leave a deck GridLAB-D cannot load), a schedule with no points (no time_points), and a NonConformLoad (its schedule is in power units: GLM's base form holds a multiplier only).
  • The DSS exporter writes a player's group as a LoadShape (DSS S8) and GDM as one shared series; RAW logs the groups' schedules as dropped (cimhub_core.getters.load_schedule.log_dropped_schedules).

X30: load schedules

The importer's S9 inverted (exporter/schedule.py, before load.py in EXPORT_ORDER): a conform group of days by season and day type (get_load_schedule's days), with their points, is a GLM schedule named after the group (GlmModel.schedules, written as a block before the objects); each ConformLoad of the group writes its bases as <schedule>*<base>.

  • Each day becomes rules: each run of equal values, split at the hours (7-59 1, * 2-5, 0-14 6), on the season's months (* for the year, 12,1-2 across December) and the day type's weekdays (DayOfWeekKind words, as the importer names them; no DayType: every day, no Season: every month). A value of 0 is no rule: GridLAB-D's value where none applies. So the atom's rules come back as written, but for spacing and number form.
  • Raise: a day whose startTime is not 00:00:00 or whose points do not fill 24 h in whole minutes; a season off whole months; a day type of another name; two days on one (month, weekday) (GridLAB-D rejects the overlap); a value2 other than value1 (as X29).
  • Written static, with X29's one warning: a group one of whose days has no points (no time_points). The DSS and GDM exporters write a group of days static and name it in their own warning: DSS has no calendar, a GDM series needs absolute times (tests/cross_format/test_glm_schedule_elsewhere.py).
  • Tests (tests/test_export_schedules.py): the rules; GridLAB-D giving the exported schedules the original's value every 30 minutes over a winter and a summer week; the written deck read back to the same points; the export golden atoms/schedule/schedule.exported.glm; the helpers and the raises.

X4: DER

  • Each PowerElectronicsUnit is an inverter (several share their connection by maxP, get_inverter_units): FOUR_QUADRANT, rated_power per phase.
  • A battery: CONSTANT_PQ at CIM's set point, soc_reserve minimumE / ratedE, max_charge_rate its StorageInverterInfo's chargeRateActiveMax (get_inverter_datasheet; max_discharge_rate has no CIM home, and both are read by LOAD_FOLLOWING only). Its battery is the internal model: capacity, state of charge, round-trip efficiency, battery_type from BatteryInfo (none: unset, GridLAB-D's UNKNOWN, as the deck it came from), nominal_voltage unset (the DCConductingAssetInfo TODO, plan §7).
  • A PV: CONSTANT_PF at CIM's power factor, GridLAB-D's own PV logic (S4b-1). Its solar carries the datasheets (get_photovoltaic_datasheet: tilt, azimuth and shading from the SolarArrayInfo, efficiency and Rated_Insolation from the SolarPanelInfo), rated_power maxP, soiling and the inverter's efficiency 1, and derating the whole loss: CIM's p over GridLAB-D's lossless static-weather output at its defaults for what CIM does not hold (panel type, NOCT; the importer's static_dc_output). So GridLAB-D's output, and the re-import's p, is CIM's p, from any origin. A p above the lossless output raises (GridLAB-D's factors are at most 1).

X5: tests

  • test_glm_writer.py: value formats, one object's text, the deck order, a read-back round trip.
  • test_export_framework.py: SLOTS cover the schema and are these tables; names; the transformer forms, the bank model, the star; regulator bank letters; the tape-shield formulas.
  • test_export_atoms.py (the export test): each importer atom deck (but the bare catalog, which line.glm includes) through the exporter and the importer again; the two CIM models equal (cimtables.diff_models, SI) under the X1 names, except the differences listed below by name; each exported deck is the golden <atom>.exported.glm beside it.
  • test_export_decks.py (GridLAB-D 6.0): the Java exports (IEEE 13 cdpsm and assets, IEEE 123) solve to the original's voltages within 1e-4, the original run as the importer reads it (a second swing a plain bus, S1-2; a CONSTANT_PF battery at its CONSTANT_PQ set point, S4b-2); the PNNL exports solve; a second pass is the same text on all five; the IEEE 13 export is the committed golden goldens/IEEE13_cdpsm/IEEE13_cdpsm.exported.glm.
  • tests/cross_format/test_dss_to_glm.py: DSS decks through CIM to GLM, against OpenDSS's own solution of one frozen state (controls off, CIM's taps, loads' models at any voltage), line to line on three-phase buses, each deck's tolerance the difference listed below. IEEE 8500 (not vendored: CIMHUB_DSS_DECKS) sets no taps, so both engines take OpenDSS's solved ones, and runs at 0.9 load: its undersized secondaries put full load past GridLAB-D's NR (it solves at 0.9, not at 1.0 with constant-impedance loads or 2000 iterations).
  • test_export_players.py (X29): the player atom's expressions, tape and clock; static loads without points, for a NonConformLoad, and the raises; IEEE 13 with GridAPPS-D's 1,440-point zipload_schedule.player (vendored) through CIM (one group, every point) and back, solved in GridLAB-D 6.0 at the schedule's first two instants against the same deck with each base fixed at K times that point (1e-9).
  • gridlabd_engine.py notes the wheel's quirks: no CLI; load errors only from DirectGridLabD; polar text misread unless complex_output_format is RECT; the Java exports need GridAPPS-D's ieeezipload player.

Expected differences

what why measured (worst, line to line unless noted)
a source's impedance is not written GLM's swing is ideal (X6) IEEE 13 original 3e-4
a VoltageRegulator's reactance and kVA GLM's regulator has neither: only its mesh r is written (regulator_resistance, S3c-2) (in the row above)
a winding's grounding impedance (rground/xground) GLM grounds a wye solidly IEEE13_CDPSM's Sub3: 3e-3 (3 % line to neutral)
a non-native two-winding model's phase shift and zero sequence the wye-wye replacement (X3) YD, GrdYD 1.4e-3
an open-delta bank as a full bank the wye-wye replacement (X3) OYOD 11 % (balanced), 16 % (unbalanced); solve only
a delta regulator bank as wye GridLAB-D 6.0 has no delta regulator under NR IEEE37 1.75 %
geometry lines' impedances each engine computes its own line constants IEEE13_Assets 2 %
an LTC's control, a capacitor's non-voltage control GLM has no form for them —
a battery's DC voltage no CIM home yet (TODO, DCConductingAssetInfo) export test: numberOfCells 11 → 28 (GridLAB-D's 115 V)
IEEE 8500 at 0.9 load not isolated (candidates: 1,177 centre-tap services, ideal regulators, X27) 5.3e-3
a triplex matrix's b GridLAB-D's triplex_line has no shunt admittance (X27) IEEE 8500: about 0.1 VAr per kft
a template no equipment uses GLM's configurations are written per use export test: the atoms' cn_250, xc_unused
a bus's nominal_voltage as the deck rounded it it is the BaseVoltage's: the deck's 2401.78 V is 4160 V / √3 export test: a regulator end's baseU, neutralU, and its ratedS and mesh x, which follow baseU (S3c-2), 1.2e-6
a load group with no schedule written static (X29): a reference to no player would not load export test: the load atoms' zipsched loads come back EnergyConsumers
a player's start zone its rows are written in GMT (X29) export test: startTime the same instant at +00:00
every slot CIM cannot hold GridLAB-D's defaults —

Slot tables

Generated from SLOTS (test_export_framework.spec_tables); every slot not listed is left unset, GridLAB-D's default.

node

GLM slot kind from / why
name written Names (X1)
phases written the A, B, C of every terminal on the node, then N
nominal_voltage written the BaseVoltage, LL / sqrt 3 on a three-phase system, LL on a single-phase one (module docstring)
bustype written SWING on the swing only
voltage_A written a one-phase swing's: get_source voltageMagnitude at voltageAngle

101 other slots: unset

triplex_node

GLM slot kind from / why
name written Names (X1)
phases written the service's letter, then S
nominal_voltage written the BaseVoltage (s1 to s2) / 2: one leg

80 other slots: unset

substation

GLM slot kind from / why
name written Names (X1)
phases written the A, B, C of every terminal on the node, then N
nominal_voltage written get_source: nominalVoltage, / sqrt 3 on a three-phase system (the importer's line_voltage inverted)
bustype written SWING on the swing only
voltage_A written a one-phase swing's: get_source voltageMagnitude at voltageAngle
positive_sequence_voltage written get_source: voltageMagnitude at voltageAngle, / sqrt 3 on a three-phase system
base_power written the graph's BasePower, when it holds one (network.base_power's 100 MVA default is not CIM's)

122 other slots: unset

overhead_line_conductor

GLM slot kind from / why
name written Names; _ when one WireInfo is two GLM classes
geometric_mean_radius written get_wire_info.gmr; unset raises
resistance written get_wire_info: rAC50 (GridLAB-D's 50 C value, the GLM importer's), else rAC25 (the DSS importer's); neither raises
diameter written 2 x get_wire_info.radius; unset: unset (GridLAB-D reads it only for line capacitance)
rating_summer_continuous written the wire's normal limit, else ratedCurrent
rating_summer_emergency written the wire's emergency limit

10 other slots: unset

triplex_line_conductor

GLM slot kind from / why
name written Names; _ when one WireInfo is two GLM classes
resistance written get_wire_info: rAC50 (GridLAB-D's 50 C value, the GLM importer's), else rAC25 (the DSS importer's); neither raises
geometric_mean_radius written get_wire_info.gmr; unset raises
rating_summer_continuous written the wire's normal limit, else ratedCurrent
rating_summer_emergency written the wire's emergency limit

10 other slots: unset

underground_line_conductor

GLM slot kind from / why
name written Names; _ when one WireInfo is two GLM classes
outer_diameter written a cable's diameterOverJacket; a bare wire's BARE_BURIED_OUTER x its diameter (rule: CIM has no jacket, GridLAB-D needs one)
conductor_gmr written get_wire_info.gmr; unset raises
conductor_diameter written 2 x get_wire_info.radius; unset: unset (GridLAB-D reads it only for line capacitance)
conductor_resistance written get_wire_info: rAC50 (GridLAB-D's 50 C value, the GLM importer's), else rAC25 (the DSS importer's); neither raises
neutral_gmr written neutralStrandGmr (ConcentricNeutralCableInfo)
neutral_diameter written 2 x neutralStrandRadius
neutral_resistance written neutralStrandRDC20
neutral_strands written neutralStrandCount
shield_thickness written tapeThickness (TapeShieldCableInfo)
shield_diameter written diameterOverScreen (TapeShieldCableInfo)
shield_gmr written tape_shield_gmr: diameterOverScreen / 2, the Java exporter's (GridLAB-D tells a tape-shield cable by shield_gmr > 0)
shield_resistance written tape_shield_resistance: Kersting eq. 4.89, the Java exporter's
rating_summer_continuous written the wire's normal limit, else ratedCurrent
rating_summer_emergency written the wire's emergency limit

11 other slots: unset

line_spacing

GLM slot kind from / why
name written Names; _ when lines use it on different phases
distance_AB written get_stored_distances between the two phases' sequence numbers; absent: unset (GridLAB-D's 0, no coupling)
distance_BC written get_stored_distances between the two phases' sequence numbers; absent: unset (GridLAB-D's 0, no coupling)
distance_AC written get_stored_distances between the two phases' sequence numbers; absent: unset (GridLAB-D's 0, no coupling)
distance_AN written get_stored_distances between the two phases' sequence numbers; absent: unset (GridLAB-D's 0, no coupling)
distance_BN written get_stored_distances between the two phases' sequence numbers; absent: unset (GridLAB-D's 0, no coupling)
distance_CN written get_stored_distances between the two phases' sequence numbers; absent: unset (GridLAB-D's 0, no coupling)
distance_AE written the stored height; an XYSpacing's y (a line with a ySpacingOffset raises)
distance_BE written the stored height; an XYSpacing's y (a line with a ySpacingOffset raises)
distance_CE written the stored height; an XYSpacing's y (a line with a ySpacingOffset raises)
distance_NE written the stored height; an XYSpacing's y (a line with a ySpacingOffset raises)

8 other slots: unset

line_configuration

GLM slot kind from / why
name written Names;