cimhub-gridlabd 2.0.0a1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cimhub_gridlabd-2.0.0a1/PKG-INFO +110 -0
- cimhub_gridlabd-2.0.0a1/README.md +89 -0
- cimhub_gridlabd-2.0.0a1/pyproject.toml +52 -0
- cimhub_gridlabd-2.0.0a1/setup.cfg +4 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/__init__.py +3 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/__init__.py +10 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/base/__init__.py +1 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/base/node.py +220 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/cim_to_glm.py +232 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/generators/__init__.py +14 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/generators/battery.py +66 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/generators/inverter.py +237 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/generators/machine.py +180 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/generators/machine_dynamics.py +100 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/generators/solar.py +49 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/glm_registry.py +8 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/glm_text_writer.py +323 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/glm_writer.py +167 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/lines/__init__.py +9 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/lines/line.py +205 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/lines/line_configuration.py +299 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/lines/line_spacing.py +245 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/lines/underground_line_conductor.py +257 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/loads/__init__.py +1 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/loads/load.py +210 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/shunts/__init__.py +2 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/shunts/capacitor.py +72 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/switches/__init__.py +3 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/switches/_common.py +98 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/switches/fuse.py +32 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/switches/recloser.py +32 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/switches/switch.py +35 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/transformers/__init__.py +6 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/transformers/regulator.py +345 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/transformers/transformer.py +146 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/transformers/transformer_configuration.py +520 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/utils/__init__.py +4 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/utils/phasing.py +163 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/exporter/utils/ratings.py +36 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/__init__.py +15 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/base/__init__.py +15 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/base/node.py +87 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/base/substation.py +47 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/base/triplex_node.py +52 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/capacitors/__init__.py +2 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/capacitors/capacitor.py +93 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/common.py +105 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/glm_reader.py +495 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/glm_registry.py +7 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/glm_serialization.py +219 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/glm_text_reader.py +346 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/glm_to_cim.py +212 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/lines/__init__.py +13 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/lines/_wire_assembly.py +90 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/lines/line_configuration.py +56 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/lines/line_spacing.py +59 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/lines/overhead_line.py +47 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/lines/overhead_line_conductor.py +33 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/lines/triplex_line.py +62 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/lines/underground_line.py +37 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/lines/underground_line_conductor.py +45 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/loads/__init__.py +2 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/loads/load.py +63 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/switches/__init__.py +2 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/switches/switch.py +31 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/transformers/__init__.py +4 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/transformers/regulator.py +128 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/transformers/transformer.py +164 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/importer/transformers/transformer_configuration.py +161 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/cpp_parser.py +269 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/gridlabd.py +27136 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/_directives/define.yaml +19 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/_directives/set.yaml +19 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/generators/battery.yaml +780 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/generators/central_dg_control.yaml +112 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/generators/controller_dg.yaml +262 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/generators/diesel_dg.yaml +2881 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/generators/energy_storage.yaml +244 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/generators/inverter.yaml +2708 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/generators/inverter_dyn.yaml +2087 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/generators/rectifier.yaml +190 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/generators/solar.yaml +645 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/generators/sync_ctrl.yaml +297 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/generators/windturb_dg.yaml +1075 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/main.yaml +115 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/billdump.yaml +73 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/capacitor.yaml +376 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/currdump.yaml +72 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/emissions.yaml +1069 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/fault_check.yaml +89 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/fuse.yaml +103 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/impedance_dump.yaml +63 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/jsondump.yaml +133 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/line.yaml +111 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/line_configuration.yaml +312 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/line_spacing.yaml +148 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/link.yaml +711 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/load.yaml +1470 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/load_tracker.yaml +111 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/meter.yaml +1248 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/motor.yaml +893 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/node.yaml +1170 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/overhead_line.yaml +31 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/overhead_line_conductor.yaml +118 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/performance_motor.yaml +407 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/power_metrics.yaml +193 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/powerflow_object.yaml +112 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/pqload.yaml +603 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/recloser.yaml +68 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/regulator.yaml +168 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/regulator_configuration.yaml +306 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/restoration.yaml +163 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/sectionalizer.yaml +31 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/series_compensator.yaml +549 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/series_reactor.yaml +144 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/substation.yaml +297 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/switch.yaml +109 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/sync_check.yaml +372 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/transformer.yaml +230 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/transformer_configuration.yaml +512 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/triplex_line.yaml +31 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/triplex_line_conductor.yaml +106 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/triplex_line_configuration.yaml +187 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/triplex_load.yaml +729 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/triplex_meter.yaml +812 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/triplex_node.yaml +822 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/underground_line.yaml +31 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/underground_line_conductor.yaml +236 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/vfd.yaml +156 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/volt_var_control.yaml +217 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/powerflow/voltdump.yaml +82 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/residential/ZIPload.yaml +372 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/residential/appliance.yaml +83 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/residential/clotheswasher.yaml +596 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/residential/dishwasher.yaml +882 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/residential/dryer.yaml +601 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/residential/evcharger.yaml +192 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/residential/evcharger_det.yaml +557 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/residential/freezer.yaml +179 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/residential/house.yaml +2171 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/residential/house_a.yaml +480 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/residential/lights.yaml +122 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/residential/microwave.yaml +126 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/residential/occupantload.yaml +68 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/residential/plugload.yaml +82 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/residential/range.yaml +711 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/residential/refrigerator.yaml +598 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/residential/thermal_storage.yaml +212 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/residential/waterheater.yaml +640 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml/types/common.yaml +2014 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/linkml_generator.py +496 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd/schema/property_parser.py +460 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd.egg-info/PKG-INFO +110 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd.egg-info/SOURCES.txt +171 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd.egg-info/dependency_links.txt +1 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd.egg-info/requires.txt +2 -0
- cimhub_gridlabd-2.0.0a1/src/cimhub_gridlabd.egg-info/top_level.txt +1 -0
- cimhub_gridlabd-2.0.0a1/tests/test_api_conformance.py +88 -0
- cimhub_gridlabd-2.0.0a1/tests/test_connectivity_node.py +161 -0
- cimhub_gridlabd-2.0.0a1/tests/test_glm_cim_glm.py +216 -0
- cimhub_gridlabd-2.0.0a1/tests/test_glm_importer.py +324 -0
- cimhub_gridlabd-2.0.0a1/tests/test_glm_json_roundtrip.py +417 -0
- cimhub_gridlabd-2.0.0a1/tests/test_glm_node.py +184 -0
- cimhub_gridlabd-2.0.0a1/tests/test_glm_text_reader.py +326 -0
- cimhub_gridlabd-2.0.0a1/tests/test_golden_diff.py +132 -0
- cimhub_gridlabd-2.0.0a1/tests/test_ieee13_roundtrip.py +393 -0
- cimhub_gridlabd-2.0.0a1/tests/test_line_ratings.py +147 -0
- cimhub_gridlabd-2.0.0a1/tests/test_machine_exporter.py +207 -0
- cimhub_gridlabd-2.0.0a1/tests/test_phase_impedance_config.py +139 -0
- cimhub_gridlabd-2.0.0a1/tests/test_regulator_exporter.py +292 -0
- cimhub_gridlabd-2.0.0a1/tests/test_schema_consistency.py +449 -0
- cimhub_gridlabd-2.0.0a1/tests/test_units_correctness.py +181 -0
- cimhub_gridlabd-2.0.0a1/tests/test_z_emit_order.py +55 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cimhub_gridlabd
|
|
3
|
+
Version: 2.0.0a1
|
|
4
|
+
Summary: CIMHub GridLAB-D Library
|
|
5
|
+
Author-email: Pacific Northwest National Laboratory <gridappsd@pnnl.gov>
|
|
6
|
+
License: BSD-2-Clause
|
|
7
|
+
Project-URL: Homepage, https://github.com/PNNL-CIM-Tools/CIMHub_2_0
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/PNNL-CIM-Tools/CIMHub_2_0/issues
|
|
9
|
+
Project-URL: Documentation, https://cimhub-gridlabd.readthedocs.io/
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
Requires-Dist: cimhub_core~=2.0.0a2
|
|
20
|
+
Requires-Dist: pandas>=2.3.3
|
|
21
|
+
|
|
22
|
+
# cimhub_gridlabd
|
|
23
|
+
|
|
24
|
+
Bidirectional converter between GridLAB-D (GLM) and CIM (IEC 61968/61970) using the `cimhub_2026` profile.
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
### GLM to CIM (Import)
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
import os
|
|
32
|
+
os.environ['CIMG_USE_UNITS'] = 'TRUE'
|
|
33
|
+
os.environ['CIMG_CIM_PROFILE'] = 'cimhub_2026'
|
|
34
|
+
|
|
35
|
+
from cimhub_gridlabd.importer.glm_to_cim import glm_to_cim
|
|
36
|
+
|
|
37
|
+
feeder = glm_to_cim("/path/to/IEEE13.glm")
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### CIM to GLM (Export)
|
|
41
|
+
|
|
42
|
+
Export is two steps: build the GLM model, then write it.
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from cimhub_gridlabd.exporter.cim_to_glm import GlmExporter
|
|
46
|
+
from cimhub_gridlabd.exporter.glm_text_writer import GlmTextWriter
|
|
47
|
+
|
|
48
|
+
glm_model = GlmExporter().to_model(feeder)
|
|
49
|
+
GlmTextWriter().write(glm_model, "/path/to/IEEE13.glm")
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`to_model` returns an in-memory `GraphModel` of GLM dataclasses, so you can
|
|
53
|
+
inspect or edit the model before it is serialized.
|
|
54
|
+
|
|
55
|
+
### JSON variant
|
|
56
|
+
|
|
57
|
+
Swap in the GLM-JSON writer (one object per JSON entry, grouped by class):
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from cimhub_gridlabd.exporter.cim_to_glm import GlmExporter
|
|
61
|
+
from cimhub_gridlabd.exporter.glm_writer import GlmJsonWriter
|
|
62
|
+
|
|
63
|
+
glm_model = GlmExporter().to_model(feeder)
|
|
64
|
+
GlmJsonWriter().write(glm_model, "/path/to/IEEE13.json")
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Or use the one-line convenience wrapper:
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from cimhub_gridlabd.exporter.cim_to_glm import cim_to_glm_json
|
|
71
|
+
|
|
72
|
+
cim_to_glm_json(feeder, "/path/to/IEEE13.json")
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Architecture
|
|
76
|
+
|
|
77
|
+
The package follows the standard CIMHub four-layer pipeline:
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
LinkML YAML → glm_schema.py → GraphModel → GlmReader / GlmWriter
|
|
81
|
+
↕
|
|
82
|
+
GlmImporter / GlmExporter
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
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.
|
|
86
|
+
|
|
87
|
+
## Equipment Coverage
|
|
88
|
+
|
|
89
|
+
| Element | Import | Export |
|
|
90
|
+
|---|---|---|
|
|
91
|
+
| Overhead lines (geometry) | ✓ | ✓ |
|
|
92
|
+
| Underground cables | ✓ | ✓ |
|
|
93
|
+
| Transformers | ✓ | ✓ |
|
|
94
|
+
| Regulators | ✓ | ✓ |
|
|
95
|
+
| Capacitor banks | ✓ | ✓ |
|
|
96
|
+
| Loads | ✓ | ✓ |
|
|
97
|
+
| Switches / reclosers / fuses | ✓ | ✓ |
|
|
98
|
+
| DER (PV, battery) | partial | partial |
|
|
99
|
+
|
|
100
|
+
## Running Tests
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
uv run pytest cimhub_gridlabd/tests/ -v
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Notes
|
|
107
|
+
|
|
108
|
+
- **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`.
|
|
109
|
+
- Python complex literals (`+0.79+0.43j`) are not valid GLM syntax — the writer uses explicit `r` / `x` fields.
|
|
110
|
+
- Phase lookups must traverse from `ACLineSegment.ACLineSegmentPhases`, not from `WireSpacingInfo.ACLineSegment[0]` (that list can be empty).
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# cimhub_gridlabd
|
|
2
|
+
|
|
3
|
+
Bidirectional converter between GridLAB-D (GLM) and CIM (IEC 61968/61970) using the `cimhub_2026` profile.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
### GLM to CIM (Import)
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
import os
|
|
11
|
+
os.environ['CIMG_USE_UNITS'] = 'TRUE'
|
|
12
|
+
os.environ['CIMG_CIM_PROFILE'] = 'cimhub_2026'
|
|
13
|
+
|
|
14
|
+
from cimhub_gridlabd.importer.glm_to_cim import glm_to_cim
|
|
15
|
+
|
|
16
|
+
feeder = glm_to_cim("/path/to/IEEE13.glm")
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### CIM to GLM (Export)
|
|
20
|
+
|
|
21
|
+
Export is two steps: build the GLM model, then write it.
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from cimhub_gridlabd.exporter.cim_to_glm import GlmExporter
|
|
25
|
+
from cimhub_gridlabd.exporter.glm_text_writer import GlmTextWriter
|
|
26
|
+
|
|
27
|
+
glm_model = GlmExporter().to_model(feeder)
|
|
28
|
+
GlmTextWriter().write(glm_model, "/path/to/IEEE13.glm")
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
`to_model` returns an in-memory `GraphModel` of GLM dataclasses, so you can
|
|
32
|
+
inspect or edit the model before it is serialized.
|
|
33
|
+
|
|
34
|
+
### JSON variant
|
|
35
|
+
|
|
36
|
+
Swap in the GLM-JSON writer (one object per JSON entry, grouped by class):
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from cimhub_gridlabd.exporter.cim_to_glm import GlmExporter
|
|
40
|
+
from cimhub_gridlabd.exporter.glm_writer import GlmJsonWriter
|
|
41
|
+
|
|
42
|
+
glm_model = GlmExporter().to_model(feeder)
|
|
43
|
+
GlmJsonWriter().write(glm_model, "/path/to/IEEE13.json")
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Or use the one-line convenience wrapper:
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from cimhub_gridlabd.exporter.cim_to_glm import cim_to_glm_json
|
|
50
|
+
|
|
51
|
+
cim_to_glm_json(feeder, "/path/to/IEEE13.json")
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Architecture
|
|
55
|
+
|
|
56
|
+
The package follows the standard CIMHub four-layer pipeline:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
LinkML YAML → glm_schema.py → GraphModel → GlmReader / GlmWriter
|
|
60
|
+
↕
|
|
61
|
+
GlmImporter / GlmExporter
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
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.
|
|
65
|
+
|
|
66
|
+
## Equipment Coverage
|
|
67
|
+
|
|
68
|
+
| Element | Import | Export |
|
|
69
|
+
|---|---|---|
|
|
70
|
+
| Overhead lines (geometry) | ✓ | ✓ |
|
|
71
|
+
| Underground cables | ✓ | ✓ |
|
|
72
|
+
| Transformers | ✓ | ✓ |
|
|
73
|
+
| Regulators | ✓ | ✓ |
|
|
74
|
+
| Capacitor banks | ✓ | ✓ |
|
|
75
|
+
| Loads | ✓ | ✓ |
|
|
76
|
+
| Switches / reclosers / fuses | ✓ | ✓ |
|
|
77
|
+
| DER (PV, battery) | partial | partial |
|
|
78
|
+
|
|
79
|
+
## Running Tests
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
uv run pytest cimhub_gridlabd/tests/ -v
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Notes
|
|
86
|
+
|
|
87
|
+
- **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`.
|
|
88
|
+
- Python complex literals (`+0.79+0.43j`) are not valid GLM syntax — the writer uses explicit `r` / `x` fields.
|
|
89
|
+
- Phase lookups must traverse from `ACLineSegment.ACLineSegmentPhases`, not from `WireSpacingInfo.ACLineSegment[0]` (that list can be empty).
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools~=80.9"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "cimhub_gridlabd"
|
|
7
|
+
description = "CIMHub GridLAB-D Library"
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
version = "2.0.0a1"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { text = "BSD-2-Clause" }
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Pacific Northwest National Laboratory", email = "gridappsd@pnnl.gov" }
|
|
14
|
+
]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
"Environment :: Console",
|
|
19
|
+
"Development Status :: 3 - Alpha",
|
|
20
|
+
"Intended Audience :: Science/Research",
|
|
21
|
+
"License :: OSI Approved :: BSD License",
|
|
22
|
+
"Topic :: Scientific/Engineering",
|
|
23
|
+
]
|
|
24
|
+
dependencies = [
|
|
25
|
+
"cimhub_core ~=2.0.0a2",
|
|
26
|
+
"pandas>=2.3.3",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
"Homepage" = "https://github.com/PNNL-CIM-Tools/CIMHub_2_0"
|
|
31
|
+
"Bug Tracker" = "https://github.com/PNNL-CIM-Tools/CIMHub_2_0/issues"
|
|
32
|
+
"Documentation" = "https://cimhub-gridlabd.readthedocs.io/"
|
|
33
|
+
|
|
34
|
+
[tool.pytest.ini_options]
|
|
35
|
+
testpaths = ["tests"]
|
|
36
|
+
addopts = "-ra -q"
|
|
37
|
+
|
|
38
|
+
[tool.coverage.report]
|
|
39
|
+
skip_empty = true
|
|
40
|
+
|
|
41
|
+
[tool.mypy]
|
|
42
|
+
strict = false
|
|
43
|
+
ignore_missing_imports = false
|
|
44
|
+
disallow_untyped_defs = false
|
|
45
|
+
warn_unused_ignores = true
|
|
46
|
+
warn_unreachable = true
|
|
47
|
+
|
|
48
|
+
[tool.setuptools]
|
|
49
|
+
packages = { find = { where = ["src"] } }
|
|
50
|
+
|
|
51
|
+
[tool.setuptools.package-data]
|
|
52
|
+
"*" = ["*.json", "*.yaml"]
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from cimhub_gridlabd.exporter.glm_writer import GlmJsonWriter
|
|
2
|
+
|
|
3
|
+
__all__ = ["GlmJsonWriter"]
|
|
4
|
+
|
|
5
|
+
# CIM conversion functions require cimgraph — only export when available
|
|
6
|
+
try:
|
|
7
|
+
from cimhub_gridlabd.exporter.cim_to_glm import cim_to_glm, cim_to_glm_json # noqa: F401
|
|
8
|
+
__all__ += ["cim_to_glm", "cim_to_glm_json"]
|
|
9
|
+
except ImportError:
|
|
10
|
+
pass
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from cimhub_gridlabd.exporter.base.node import convert_connectivity_node
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import importlib
|
|
4
|
+
import logging
|
|
5
|
+
import math
|
|
6
|
+
|
|
7
|
+
import cimgraph.data_profile.cimhub_2026 as cim
|
|
8
|
+
|
|
9
|
+
from cimhub_core import GraphModel
|
|
10
|
+
from cimhub_gridlabd.schema import gridlabd as glm_schema
|
|
11
|
+
from cimhub_gridlabd.exporter.glm_registry import glm_exporter_registry
|
|
12
|
+
from cimhub_gridlabd.exporter.utils.phasing import collect_phases
|
|
13
|
+
|
|
14
|
+
_log = logging.getLogger(__name__)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _voltage_from_transformer(terminal, xfmr, cim_mod) -> float | None:
|
|
18
|
+
"""Return the rated voltage (V, line-to-line) for this terminal's side of xfmr.
|
|
19
|
+
|
|
20
|
+
Walks PowerTransformerEnds + TransformerTankEnds looking for an end whose
|
|
21
|
+
Terminal matches *terminal*. Returns ``ratedU`` (in V) if found.
|
|
22
|
+
"""
|
|
23
|
+
for end in getattr(xfmr, "PowerTransformerEnd", []):
|
|
24
|
+
if getattr(end, "Terminal", None) is terminal:
|
|
25
|
+
v = getattr(end, "ratedU", None)
|
|
26
|
+
if v is not None:
|
|
27
|
+
return float(v)
|
|
28
|
+
for tank in getattr(xfmr, "TransformerTanks", []):
|
|
29
|
+
for end in getattr(tank, "TransformerTankEnds", []):
|
|
30
|
+
if getattr(end, "Terminal", None) is terminal:
|
|
31
|
+
v = getattr(end, "ratedU", None)
|
|
32
|
+
if v is not None:
|
|
33
|
+
return float(v)
|
|
34
|
+
return None
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@glm_exporter_registry.register(cim.ConnectivityNode)
|
|
38
|
+
def convert_connectivity_node(node: cim.ConnectivityNode, glm_model: GraphModel) -> dict:
|
|
39
|
+
cim: cim = importlib.import_module(node.__module__)
|
|
40
|
+
|
|
41
|
+
phases = []
|
|
42
|
+
ll_voltages: list[float] = [] # line-to-line (from BaseVoltage) — divide by sqrt(3)
|
|
43
|
+
ln_voltages: list[float] = [] # line-to-neutral (from transformer ratedU) — use as-is
|
|
44
|
+
is_swing_bus = False
|
|
45
|
+
is_swing_pq = False
|
|
46
|
+
is_triplex = False
|
|
47
|
+
glm_node = {}
|
|
48
|
+
glm_node["name"] = node.name or node.uri()
|
|
49
|
+
|
|
50
|
+
# Collect phasing and nominal voltage
|
|
51
|
+
for terminal in node.Terminals:
|
|
52
|
+
equipment = terminal.ConductingEquipment
|
|
53
|
+
if equipment is None:
|
|
54
|
+
continue
|
|
55
|
+
|
|
56
|
+
# Swing bus detection: EnergySource or a regulating network injection.
|
|
57
|
+
# CIM17 calls it EquivalentInjection; CIM18/cimhub_2026 renamed it
|
|
58
|
+
# ExternalNetworkInjection. Match whichever the profile defines.
|
|
59
|
+
injection_cls = getattr(cim, "ExternalNetworkInjection", None) or getattr(
|
|
60
|
+
cim, "EquivalentInjection", None
|
|
61
|
+
)
|
|
62
|
+
if isinstance(equipment, cim.EnergySource):
|
|
63
|
+
is_swing_bus = True
|
|
64
|
+
elif injection_cls is not None and isinstance(equipment, injection_cls):
|
|
65
|
+
if getattr(equipment, "regulationStatus", False):
|
|
66
|
+
is_swing_bus = True
|
|
67
|
+
|
|
68
|
+
if equipment.BaseVoltage is not None:
|
|
69
|
+
# BaseVoltage.nominalVoltage is line-to-line — convert to LN later
|
|
70
|
+
ll_voltages.append(float(equipment.BaseVoltage.nominalVoltage))
|
|
71
|
+
elif isinstance(equipment, cim.PowerTransformer):
|
|
72
|
+
# TransformerEnd.Terminal back-ref may be empty — walk the transformer
|
|
73
|
+
# ends directly and match by terminal to find the rated voltage.
|
|
74
|
+
# TransformerEnd.ratedU is line-to-line for multi-phase ends; for single-
|
|
75
|
+
# phase (center-tap) ends it's line-to-neutral. Both are stored as V.
|
|
76
|
+
# We track these separately so we can later pick the right one.
|
|
77
|
+
v = _voltage_from_transformer(terminal, equipment, cim)
|
|
78
|
+
if v is not None:
|
|
79
|
+
ln_voltages.append(float(v))
|
|
80
|
+
else:
|
|
81
|
+
# For switches/lines with no BaseVoltage, look through the OTHER terminal
|
|
82
|
+
# of the same equipment to its connectivity node's equipment BaseVoltage.
|
|
83
|
+
for other_t in getattr(equipment, "Terminals", []):
|
|
84
|
+
if other_t is terminal:
|
|
85
|
+
continue
|
|
86
|
+
other_cn = getattr(other_t, "ConnectivityNode", None)
|
|
87
|
+
if other_cn is None:
|
|
88
|
+
continue
|
|
89
|
+
for other_t2 in getattr(other_cn, "Terminals", []):
|
|
90
|
+
eq2 = other_t2.ConductingEquipment
|
|
91
|
+
if eq2 is equipment:
|
|
92
|
+
continue
|
|
93
|
+
if getattr(eq2, "BaseVoltage", None) is not None:
|
|
94
|
+
ll_voltages.append(float(eq2.BaseVoltage.nominalVoltage))
|
|
95
|
+
break
|
|
96
|
+
if ll_voltages:
|
|
97
|
+
break
|
|
98
|
+
|
|
99
|
+
phases.append(collect_phases(equipment))
|
|
100
|
+
|
|
101
|
+
# Detect triplex (secondary system) nodes
|
|
102
|
+
if "S" in "".join(phases):
|
|
103
|
+
is_triplex = True
|
|
104
|
+
|
|
105
|
+
# Detect DER types connected to this node — used for sub-meter emission and
|
|
106
|
+
# SWING_PQ classification (matches Java GldNode.bSolarInverters / bStorageInverters
|
|
107
|
+
# / bSyncMachines flags).
|
|
108
|
+
has_pv = False
|
|
109
|
+
has_storage = False
|
|
110
|
+
has_sync = False
|
|
111
|
+
for terminal in node.Terminals:
|
|
112
|
+
eq = terminal.ConductingEquipment
|
|
113
|
+
if isinstance(eq, cim.PowerElectronicsConnection):
|
|
114
|
+
for unit in (eq.PowerElectronicsUnit or []):
|
|
115
|
+
if isinstance(unit, cim.PhotoVoltaicUnit):
|
|
116
|
+
has_pv = True
|
|
117
|
+
elif isinstance(unit, cim.BatteryUnit):
|
|
118
|
+
has_storage = True
|
|
119
|
+
elif isinstance(eq, cim.SynchronousMachine):
|
|
120
|
+
has_sync = True
|
|
121
|
+
|
|
122
|
+
# Assign phases to node. Java appends "N" for primary nodes via GetPhases(false)
|
|
123
|
+
# and "S" for secondary. Python replicates that here.
|
|
124
|
+
sorted_phases = sorted("".join(set(sorted("".join(phases)))))
|
|
125
|
+
if is_triplex:
|
|
126
|
+
# collect_phases already returns the secondary form as "<letter>S", so the
|
|
127
|
+
# letters here may already carry the S — appending another would emit "CSS".
|
|
128
|
+
# GridLAB-D needs "<letter>S" ("CS"), never a bare "S": a bare S compiles
|
|
129
|
+
# but leaves the triplex with no primary phase, which surfaces as wrong
|
|
130
|
+
# secondary voltages at run time rather than as a load-time error.
|
|
131
|
+
letters = "".join(p for p in sorted_phases if p != "S")
|
|
132
|
+
if not letters:
|
|
133
|
+
raise ValueError(
|
|
134
|
+
f"node {node.name}: triplex node has no primary phase letter "
|
|
135
|
+
f"(collected {phases!r}); GridLAB-D requires 'AS'/'BS'/'CS'"
|
|
136
|
+
)
|
|
137
|
+
glm_node["phases"] = letters + "S"
|
|
138
|
+
elif sorted_phases:
|
|
139
|
+
glm_node["phases"] = "".join(sorted_phases) + "N"
|
|
140
|
+
else:
|
|
141
|
+
glm_node["phases"] = "ABCN"
|
|
142
|
+
|
|
143
|
+
# Assign base voltage to node.
|
|
144
|
+
# BaseVoltage.nominalVoltage is line-to-line (LL); divide by sqrt(3) or 2.
|
|
145
|
+
# TransformerEnd.ratedU is used as-is (already LN for the relevant end).
|
|
146
|
+
# Prefer the LL source (more common/reliable) when available.
|
|
147
|
+
ll_to_ln = 2.0 if is_triplex else math.sqrt(3)
|
|
148
|
+
if ll_voltages:
|
|
149
|
+
ln_cand = [v / ll_to_ln for v in set(ll_voltages)]
|
|
150
|
+
elif ln_voltages:
|
|
151
|
+
ln_cand = list(set(ln_voltages))
|
|
152
|
+
else:
|
|
153
|
+
ln_cand = []
|
|
154
|
+
|
|
155
|
+
if len(ln_cand) == 0:
|
|
156
|
+
_log.warning(f"Unable to determine base voltage of Node {node.name}")
|
|
157
|
+
glm_node["nominal_voltage"] = None
|
|
158
|
+
else:
|
|
159
|
+
if len(ln_cand) > 1:
|
|
160
|
+
_log.warning(f"Node {node.name} has multiple voltages; using lowest")
|
|
161
|
+
glm_node["nominal_voltage"] = min(ln_cand)
|
|
162
|
+
|
|
163
|
+
node_name = glm_node["name"]
|
|
164
|
+
|
|
165
|
+
# Convert dict to appropriate GLM schema dataclass
|
|
166
|
+
if is_swing_bus:
|
|
167
|
+
glm_node["bustype"] = "SWING"
|
|
168
|
+
# These values were hard-coded previously, keeping the same
|
|
169
|
+
glm_node["base_power"] = "12MVA"
|
|
170
|
+
glm_node["positive_sequence_voltage"] = "${VSOURCE}"
|
|
171
|
+
glm_node["power_convergence_value"] = "100VA"
|
|
172
|
+
glm_node["outside_comments"] = [f"EnergySource Name:{node.name}"]
|
|
173
|
+
|
|
174
|
+
# Create Substation dataclass instance
|
|
175
|
+
substation = glm_schema.Substation()
|
|
176
|
+
for key, value in glm_node.items():
|
|
177
|
+
setattr(substation, key, value)
|
|
178
|
+
glm_model.add_to_graph(substation)
|
|
179
|
+
|
|
180
|
+
elif is_triplex:
|
|
181
|
+
glm_node["outside_comments"] = [f"Name:{node.name}"]
|
|
182
|
+
|
|
183
|
+
# Create TriplexNode dataclass instance
|
|
184
|
+
triplex_node = glm_schema.TriplexNode()
|
|
185
|
+
for key, value in glm_node.items():
|
|
186
|
+
setattr(triplex_node, key, value)
|
|
187
|
+
glm_model.add_to_graph(triplex_node)
|
|
188
|
+
|
|
189
|
+
# Sub-meters for DER at triplex (secondary) nodes — mirrors Java AppendSubMeter
|
|
190
|
+
for suffix, present in (("_pvmtr", has_pv), ("_stmtr", has_storage), ("_dgmtr", has_sync)):
|
|
191
|
+
if not present:
|
|
192
|
+
continue
|
|
193
|
+
sub = glm_schema.TriplexMeter()
|
|
194
|
+
sub.name = node_name + suffix
|
|
195
|
+
sub.parent = node_name
|
|
196
|
+
sub.phases = glm_node["phases"]
|
|
197
|
+
sub.nominal_voltage = glm_node["nominal_voltage"]
|
|
198
|
+
glm_model.add_to_graph(sub)
|
|
199
|
+
|
|
200
|
+
else:
|
|
201
|
+
if has_storage or has_sync:
|
|
202
|
+
glm_node["bustype"] = "SWING_PQ"
|
|
203
|
+
glm_node["outside_comments"] = [f"Name:{node.name}"]
|
|
204
|
+
|
|
205
|
+
# Create Node dataclass instance
|
|
206
|
+
node_obj = glm_schema.Node()
|
|
207
|
+
for key, value in glm_node.items():
|
|
208
|
+
setattr(node_obj, key, value)
|
|
209
|
+
glm_model.add_to_graph(node_obj)
|
|
210
|
+
|
|
211
|
+
# Sub-meters for DER at primary nodes — mirrors Java AppendSubMeter
|
|
212
|
+
for suffix, present in (("_pvmtr", has_pv), ("_stmtr", has_storage), ("_dgmtr", has_sync)):
|
|
213
|
+
if not present:
|
|
214
|
+
continue
|
|
215
|
+
sub = glm_schema.Meter()
|
|
216
|
+
sub.name = node_name + suffix
|
|
217
|
+
sub.parent = node_name
|
|
218
|
+
sub.phases = glm_node["phases"]
|
|
219
|
+
sub.nominal_voltage = glm_node["nominal_voltage"]
|
|
220
|
+
glm_model.add_to_graph(sub)
|