cimhub-opendss 2.0.0a0__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.
Files changed (192) hide show
  1. cimhub_opendss-2.0.0a0/PKG-INFO +100 -0
  2. cimhub_opendss-2.0.0a0/README.md +78 -0
  3. cimhub_opendss-2.0.0a0/pyproject.toml +54 -0
  4. cimhub_opendss-2.0.0a0/setup.cfg +4 -0
  5. cimhub_opendss-2.0.0a0/src/cimhub_opendss/__init__.py +3 -0
  6. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/__init__.py +0 -0
  7. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/cim_to_dss.py +414 -0
  8. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/conductors/__init__.py +17 -0
  9. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/conductors/cndata.py +59 -0
  10. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/conductors/conductor_distance_spacing.py +127 -0
  11. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/conductors/linegeometry.py +72 -0
  12. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/conductors/linespacing.py +57 -0
  13. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/conductors/tsdata.py +58 -0
  14. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/conductors/wiredata.py +59 -0
  15. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/dss_registry.py +8 -0
  16. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/dss_writer.py +137 -0
  17. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/generators/__init__.py +7 -0
  18. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/generators/generator.py +58 -0
  19. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/lines/__init__.py +9 -0
  20. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/lines/ac_line_segment.py +288 -0
  21. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/lines/per_length_impedance.py +186 -0
  22. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/loads/__init__.py +7 -0
  23. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/loads/energy_consumer.py +317 -0
  24. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/pvsystems/__init__.py +7 -0
  25. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/pvsystems/pvsystem.py +124 -0
  26. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/reactors/__init__.py +5 -0
  27. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/reactors/series_compensator.py +66 -0
  28. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/regulators/__init__.py +5 -0
  29. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/regulators/regcontrol.py +139 -0
  30. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/shunts/__init__.py +9 -0
  31. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/shunts/capacitor.py +161 -0
  32. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/shunts/capcontrol.py +136 -0
  33. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/storage/__init__.py +7 -0
  34. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/storage/storage.py +123 -0
  35. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/switches/__init__.py +13 -0
  36. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/switches/breaker.py +26 -0
  37. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/switches/fuse.py +26 -0
  38. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/switches/load_break_switch.py +58 -0
  39. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/switches/recloser.py +26 -0
  40. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/transformers/__init__.py +13 -0
  41. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/transformers/power_transformer.py +359 -0
  42. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/transformers/regcontrol.py +96 -0
  43. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/transformers/transformer_tank.py +212 -0
  44. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/transformers/xfmrcode.py +161 -0
  45. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/vsources/__init__.py +7 -0
  46. cimhub_opendss-2.0.0a0/src/cimhub_opendss/exporter/vsources/energy_source.py +112 -0
  47. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/__init__.py +1 -0
  48. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/capacitors/__init__.py +6 -0
  49. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/capacitors/capacitor.py +338 -0
  50. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/capacitors/capcontrol.py +205 -0
  51. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/common/__init__.py +59 -0
  52. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/common/base_voltage.py +54 -0
  53. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/common/connection_handling.py +49 -0
  54. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/common/phase_handling.py +264 -0
  55. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/common/terminal_creation.py +194 -0
  56. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/common/units.py +82 -0
  57. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/common/validation.py +230 -0
  58. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/conductors/__init__.py +24 -0
  59. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/conductors/cndata.py +118 -0
  60. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/conductors/linegeometry.py +241 -0
  61. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/conductors/linespacing.py +118 -0
  62. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/conductors/tsdata.py +117 -0
  63. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/conductors/wiredata.py +118 -0
  64. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/dss_name_map.py +291 -0
  65. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/dss_reader.py +1529 -0
  66. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/dss_registry.py +13 -0
  67. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/dss_to_cim.py +644 -0
  68. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/generators/__init__.py +5 -0
  69. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/generators/generator.py +148 -0
  70. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/lines/__init__.py +9 -0
  71. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/lines/line.py +559 -0
  72. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/lines/linecode.py +240 -0
  73. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/loads/__init__.py +9 -0
  74. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/loads/load.py +357 -0
  75. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/pvsystems/__init__.py +5 -0
  76. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/pvsystems/pvsystem.py +222 -0
  77. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/reactors/__init__.py +5 -0
  78. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/reactors/reactor.py +120 -0
  79. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/regulators/__init__.py +5 -0
  80. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/regulators/regcontrol.py +235 -0
  81. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/storage/__init__.py +5 -0
  82. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/storage/storage.py +269 -0
  83. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/switches/__init__.py +0 -0
  84. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/switches/switch.py +147 -0
  85. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/transformers/__init__.py +15 -0
  86. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/transformers/autotrans.py +317 -0
  87. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/transformers/transformer.py +907 -0
  88. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/transformers/vector_group.py +88 -0
  89. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/transformers/xfmrcode.py +282 -0
  90. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/vsources/__init__.py +5 -0
  91. cimhub_opendss-2.0.0a0/src/cimhub_opendss/importer/vsources/vsource.py +221 -0
  92. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/__init__.py +0 -0
  93. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/common_enums.yaml +229 -0
  94. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/controls/capcontrol.yaml +386 -0
  95. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/controls/espvlcontrol.yaml +165 -0
  96. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/controls/expcontrol.yaml +183 -0
  97. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/controls/fuse.yaml +147 -0
  98. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/controls/gendispatcher.yaml +111 -0
  99. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/controls/invcontrol.yaml +363 -0
  100. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/controls/pycontrol.yaml +66 -0
  101. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/controls/recloser.yaml +273 -0
  102. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/controls/regcontrol.yaml +527 -0
  103. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/controls/relay.yaml +511 -0
  104. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/controls/storagecontroller.yaml +395 -0
  105. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/controls/swtcontrol.yaml +129 -0
  106. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/controls/upfccontrol.yaml +66 -0
  107. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/general/cndata.yaml +239 -0
  108. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/general/dynamicexp.yaml +93 -0
  109. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/general/growthshape.yaml +93 -0
  110. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/general/linecode.yaml +409 -0
  111. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/general/linegeometry.yaml +240 -0
  112. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/general/linespacing.yaml +178 -0
  113. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/general/loadshape.yaml +246 -0
  114. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/general/priceshape.yaml +147 -0
  115. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/general/spectrum.yaml +85 -0
  116. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/general/tcc_curve.yaml +66 -0
  117. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/general/tsdata.yaml +221 -0
  118. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/general/tshape.yaml +147 -0
  119. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/general/wiredata.yaml +231 -0
  120. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/general/xfmrcode.yaml +566 -0
  121. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/general/xycurve.yaml +156 -0
  122. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/meters/energymeter.yaml +274 -0
  123. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/meters/fmonitor.yaml +309 -0
  124. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/meters/monitor.yaml +120 -0
  125. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/meters/sensor.yaml +175 -0
  126. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/opendss.yaml +77 -0
  127. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/other/fault.yaml +184 -0
  128. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/other/gicsource.yaml +156 -0
  129. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/other/isource.yaml +165 -0
  130. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/other/vsource.yaml +491 -0
  131. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/pce/capacitor.yaml +389 -0
  132. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/pce/generator.yaml +773 -0
  133. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/pce/generic5.yaml +498 -0
  134. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/pce/gicline.yaml +201 -0
  135. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/pce/indmach012.yaml +255 -0
  136. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/pce/load.yaml +616 -0
  137. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/pce/pvsystem.yaml +723 -0
  138. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/pce/storage.yaml +860 -0
  139. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/pce/upfc.yaml +219 -0
  140. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/pce/vccs.yaml +183 -0
  141. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/pce/vsconverter.yaml +237 -0
  142. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/pce/windgen.yaml +463 -0
  143. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/pde/autotrans.yaml +700 -0
  144. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/pde/capacitor.yaml +356 -0
  145. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/pde/gictransformer.yaml +239 -0
  146. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/pde/line.yaml +674 -0
  147. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/pde/reactor.yaml +375 -0
  148. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/linkml/pde/transformer.yaml +931 -0
  149. cimhub_opendss-2.0.0a0/src/cimhub_opendss/schema/opendss_schema.py +11430 -0
  150. cimhub_opendss-2.0.0a0/src/cimhub_opendss.egg-info/PKG-INFO +100 -0
  151. cimhub_opendss-2.0.0a0/src/cimhub_opendss.egg-info/SOURCES.txt +190 -0
  152. cimhub_opendss-2.0.0a0/src/cimhub_opendss.egg-info/dependency_links.txt +1 -0
  153. cimhub_opendss-2.0.0a0/src/cimhub_opendss.egg-info/requires.txt +3 -0
  154. cimhub_opendss-2.0.0a0/src/cimhub_opendss.egg-info/top_level.txt +1 -0
  155. cimhub_opendss-2.0.0a0/tests/test_9500_roundtrip.py +252 -0
  156. cimhub_opendss-2.0.0a0/tests/test_api_conformance.py +16 -0
  157. cimhub_opendss-2.0.0a0/tests/test_autotrans.py +167 -0
  158. cimhub_opendss-2.0.0a0/tests/test_capacitor.py +322 -0
  159. cimhub_opendss-2.0.0a0/tests/test_capacitor_roundtrip.py +431 -0
  160. cimhub_opendss-2.0.0a0/tests/test_capcontrol_roundtrip.py +176 -0
  161. cimhub_opendss-2.0.0a0/tests/test_cndata.py +109 -0
  162. cimhub_opendss-2.0.0a0/tests/test_dss_reader.py +591 -0
  163. cimhub_opendss-2.0.0a0/tests/test_dss_roundtrip.py +184 -0
  164. cimhub_opendss-2.0.0a0/tests/test_generator_importer.py +144 -0
  165. cimhub_opendss-2.0.0a0/tests/test_generator_roundtrip.py +184 -0
  166. cimhub_opendss-2.0.0a0/tests/test_ieee13_assets_roundtrip.py +228 -0
  167. cimhub_opendss-2.0.0a0/tests/test_ieee13_roundtrip.py +226 -0
  168. cimhub_opendss-2.0.0a0/tests/test_line.py +408 -0
  169. cimhub_opendss-2.0.0a0/tests/test_line_roundtrip.py +591 -0
  170. cimhub_opendss-2.0.0a0/tests/test_linecode.py +436 -0
  171. cimhub_opendss-2.0.0a0/tests/test_linecode_roundtrip.py +385 -0
  172. cimhub_opendss-2.0.0a0/tests/test_linegeometry.py +187 -0
  173. cimhub_opendss-2.0.0a0/tests/test_linespacing.py +127 -0
  174. cimhub_opendss-2.0.0a0/tests/test_load.py +264 -0
  175. cimhub_opendss-2.0.0a0/tests/test_load_roundtrip.py +511 -0
  176. cimhub_opendss-2.0.0a0/tests/test_orchestrator.py +176 -0
  177. cimhub_opendss-2.0.0a0/tests/test_pvsystem_importer.py +192 -0
  178. cimhub_opendss-2.0.0a0/tests/test_pvsystem_roundtrip.py +242 -0
  179. cimhub_opendss-2.0.0a0/tests/test_regcontrol_roundtrip.py +337 -0
  180. cimhub_opendss-2.0.0a0/tests/test_storage_importer.py +217 -0
  181. cimhub_opendss-2.0.0a0/tests/test_storage_roundtrip.py +284 -0
  182. cimhub_opendss-2.0.0a0/tests/test_switch_roundtrip.py +226 -0
  183. cimhub_opendss-2.0.0a0/tests/test_transformer.py +518 -0
  184. cimhub_opendss-2.0.0a0/tests/test_transformer_roundtrip.py +746 -0
  185. cimhub_opendss-2.0.0a0/tests/test_tsdata.py +101 -0
  186. cimhub_opendss-2.0.0a0/tests/test_vector_group.py +91 -0
  187. cimhub_opendss-2.0.0a0/tests/test_vsource.py +314 -0
  188. cimhub_opendss-2.0.0a0/tests/test_vsource_roundtrip.py +225 -0
  189. cimhub_opendss-2.0.0a0/tests/test_wiredata.py +123 -0
  190. cimhub_opendss-2.0.0a0/tests/test_wiredata_roundtrip.py +503 -0
  191. cimhub_opendss-2.0.0a0/tests/test_xfmrcode.py +177 -0
  192. cimhub_opendss-2.0.0a0/tests/test_xfmrcode_roundtrip.py +140 -0
@@ -0,0 +1,100 @@
1
+ Metadata-Version: 2.4
2
+ Name: cimhub_opendss
3
+ Version: 2.0.0a0
4
+ Summary: CIMHub OpenDSS 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://pnnl-cim-tools.github.io/CIMHub_2_0/cimhub_opendss/
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.1,>=2.0.0a0
20
+ Requires-Dist: cim-graph==0.5.0a3
21
+ Requires-Dist: OpenDSSDirect.py~=0.9.4
22
+
23
+ # Cimhub OpenDSS
24
+
25
+ Bidirectional converter between OpenDSS and CIM (IEC 61968/61970) using the `cimhub_2026` profile.
26
+
27
+ ## Usage
28
+
29
+ ### DSS to CIM (Import)
30
+
31
+ ```python
32
+ import os
33
+ os.environ['CIMG_USE_UNITS'] = 'TRUE'
34
+ os.environ['CIMG_CIM_PROFILE'] = 'cimhub_2026'
35
+
36
+ from cimhub_opendss.importer.dss_to_cim import dss_to_cim
37
+
38
+ feeder = dss_to_cim("/path/to/Master.dss")
39
+ ```
40
+
41
+ ### CIM to DSS (Export)
42
+
43
+ ```python
44
+ from cimhub_opendss.exporter.cim_to_dss import cim_to_dss
45
+
46
+ cim_to_dss(feeder, "/path/to/output_dir")
47
+ # Writes Master.dss + per-component .dss files
48
+ ```
49
+
50
+ ### Roundtrip Validation
51
+
52
+ A full DSS -> CIM -> DSS roundtrip integration test is provided for the IEEE 13-bus feeder:
53
+
54
+ ```bash
55
+ uv run python cimhub_opendss/tests/test_ieee13_roundtrip.py
56
+ # or via pytest:
57
+ uv run pytest cimhub_opendss/tests/test_ieee13_roundtrip.py -vs
58
+ ```
59
+
60
+ The roundtrip parses the IEEE 13-bus DSS model, imports to CIM, exports back to DSS,
61
+ solves both models with OpenDSS, and compares total power and bus voltages. Current
62
+ accuracy is within 0.14% on active power (4.4 kW on a 3230 kW system).
63
+
64
+ ## Models
65
+
66
+ ### Mandatory
67
+
68
+ - [x] Power Transformer
69
+ - [x] Transformers
70
+ - [x] Regulator Controls
71
+ - [x] Line Code
72
+ - [x] Line
73
+ - [x] Capacitor
74
+ - [x] Load
75
+ - [x] PV System
76
+ - [x] Storage
77
+ - [x] Switch
78
+ - [x] Fuse
79
+ - [x] Recloser
80
+ - [x] Breaker
81
+ - [x] Generator
82
+ - [ ] CNData (importer only)
83
+ - [ ] TSData (importer only)
84
+ - [ ] Line Geometry (importer only)
85
+ - [ ] Line Spacing (importer only)
86
+ - [x] Wire Data
87
+ - [ ] XY Curve
88
+
89
+ ### As Needed
90
+
91
+ - [ ] GIC Transformer
92
+ - [ ] GIC Line
93
+ - [ ] Induction Machine
94
+ - [ ] UPFC Device
95
+ - [ ] Wind Generator
96
+ - [x] Capacitor Control
97
+ - [ ] Inverter Control
98
+ - [ ] Storage Control
99
+ - [ ] Switch Control
100
+ - [ ] UPFC Control
@@ -0,0 +1,78 @@
1
+ # Cimhub OpenDSS
2
+
3
+ Bidirectional converter between OpenDSS and CIM (IEC 61968/61970) using the `cimhub_2026` profile.
4
+
5
+ ## Usage
6
+
7
+ ### DSS 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_opendss.importer.dss_to_cim import dss_to_cim
15
+
16
+ feeder = dss_to_cim("/path/to/Master.dss")
17
+ ```
18
+
19
+ ### CIM to DSS (Export)
20
+
21
+ ```python
22
+ from cimhub_opendss.exporter.cim_to_dss import cim_to_dss
23
+
24
+ cim_to_dss(feeder, "/path/to/output_dir")
25
+ # Writes Master.dss + per-component .dss files
26
+ ```
27
+
28
+ ### Roundtrip Validation
29
+
30
+ A full DSS -> CIM -> DSS roundtrip integration test is provided for the IEEE 13-bus feeder:
31
+
32
+ ```bash
33
+ uv run python cimhub_opendss/tests/test_ieee13_roundtrip.py
34
+ # or via pytest:
35
+ uv run pytest cimhub_opendss/tests/test_ieee13_roundtrip.py -vs
36
+ ```
37
+
38
+ The roundtrip parses the IEEE 13-bus DSS model, imports to CIM, exports back to DSS,
39
+ solves both models with OpenDSS, and compares total power and bus voltages. Current
40
+ accuracy is within 0.14% on active power (4.4 kW on a 3230 kW system).
41
+
42
+ ## Models
43
+
44
+ ### Mandatory
45
+
46
+ - [x] Power Transformer
47
+ - [x] Transformers
48
+ - [x] Regulator Controls
49
+ - [x] Line Code
50
+ - [x] Line
51
+ - [x] Capacitor
52
+ - [x] Load
53
+ - [x] PV System
54
+ - [x] Storage
55
+ - [x] Switch
56
+ - [x] Fuse
57
+ - [x] Recloser
58
+ - [x] Breaker
59
+ - [x] Generator
60
+ - [ ] CNData (importer only)
61
+ - [ ] TSData (importer only)
62
+ - [ ] Line Geometry (importer only)
63
+ - [ ] Line Spacing (importer only)
64
+ - [x] Wire Data
65
+ - [ ] XY Curve
66
+
67
+ ### As Needed
68
+
69
+ - [ ] GIC Transformer
70
+ - [ ] GIC Line
71
+ - [ ] Induction Machine
72
+ - [ ] UPFC Device
73
+ - [ ] Wind Generator
74
+ - [x] Capacitor Control
75
+ - [ ] Inverter Control
76
+ - [ ] Storage Control
77
+ - [ ] Switch Control
78
+ - [ ] UPFC Control
@@ -0,0 +1,54 @@
1
+ [build-system]
2
+ requires = ["setuptools~=80.9"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "cimhub_opendss"
7
+ description = "CIMHub OpenDSS Library"
8
+ readme = "README.md"
9
+ version = "2.0.0a0"
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
+
25
+ dependencies = [
26
+ "cimhub_core >=2.0.0a0,<2.1",
27
+ "cim-graph ==0.5.0a3",
28
+ "OpenDSSDirect.py ~=0.9.4"
29
+ ]
30
+
31
+ [project.urls]
32
+ "Homepage" = "https://github.com/PNNL-CIM-Tools/CIMHub_2_0"
33
+ "Bug Tracker" = "https://github.com/PNNL-CIM-Tools/CIMHub_2_0/issues"
34
+ "Documentation" = "https://pnnl-cim-tools.github.io/CIMHub_2_0/cimhub_opendss/"
35
+
36
+ [tool.pytest.ini_options]
37
+ testpaths = ["tests"]
38
+ addopts = "-ra -q"
39
+
40
+ [tool.coverage.report]
41
+ skip_empty = true
42
+
43
+ [tool.mypy]
44
+ strict = false
45
+ ignore_missing_imports = false
46
+ disallow_untyped_defs = false
47
+ warn_unused_ignores = true
48
+ warn_unreachable = true
49
+
50
+ [tool.setuptools]
51
+ packages = { find = { where = ["src"] } }
52
+
53
+ [tool.setuptools.package-data]
54
+ "*" = ["*.json", "*.yaml"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ """CIMHub OpenDSS — bidirectional OpenDSS ↔ CIM converter."""
2
+
3
+ __version__ = "2.0.0a0"
@@ -0,0 +1,414 @@
1
+ """CIM to OpenDSS converter orchestrator.
2
+
3
+ This module coordinates the conversion from CIM (cimgraph) to OpenDSS format
4
+ following the cimhub architecture pattern:
5
+
6
+ CIM FeederModel -> registered converters -> LinkML schema objects -> DSSWriter -> .dss files
7
+
8
+ The conversion process:
9
+ 1. Iterate CIM objects in dependency order
10
+ 2. Convert each to LinkML-generated DSS schema dataclass(es) via the registry
11
+ 3. Serialize to DSS command strings using DSSWriter
12
+ 4. Write to per-component .dss files
13
+ """
14
+ from __future__ import annotations
15
+
16
+ import logging
17
+ from pathlib import Path
18
+
19
+ import cimgraph.data_profile.cimhub_2026 as cim
20
+ from cimgraph.models import FeederModel
21
+
22
+ from cimhub_core import FormatExporter
23
+ from cimhub_opendss.exporter.dss_registry import dss_exporter_registry
24
+ from cimhub_opendss.exporter.dss_writer import DSSWriter
25
+
26
+ # Trigger converter registration by importing domain packages
27
+ import cimhub_opendss.exporter.loads # noqa: F401
28
+ import cimhub_opendss.exporter.shunts # noqa: F401
29
+ import cimhub_opendss.exporter.lines # noqa: F401
30
+ import cimhub_opendss.exporter.transformers # noqa: F401
31
+ import cimhub_opendss.exporter.vsources # noqa: F401
32
+ import cimhub_opendss.exporter.switches # noqa: F401
33
+ import cimhub_opendss.exporter.pvsystems # noqa: F401
34
+ import cimhub_opendss.exporter.storage # noqa: F401
35
+ import cimhub_opendss.exporter.generators # noqa: F401
36
+ import cimhub_opendss.exporter.conductors # noqa: F401
37
+ import cimhub_opendss.exporter.regulators # noqa: F401
38
+ import cimhub_opendss.exporter.reactors # noqa: F401
39
+
40
+ _log = logging.getLogger(__name__)
41
+
42
+ __all__ = ["cim_to_dss", "DssExporter"]
43
+
44
+
45
+ class DssExporter(FormatExporter):
46
+ """CIM → OpenDSS exporter implementing the :class:`FormatExporter` contract.
47
+
48
+ The :func:`cim_to_dss` convenience function delegates here. See
49
+ ``cimhub_core/development/CONVERTER_API.md``.
50
+ """
51
+
52
+ def to_format(
53
+ self,
54
+ network: FeederModel,
55
+ destination: str | Path,
56
+ **opts,
57
+ ) -> dict[str, list[str]]:
58
+ """Convert *network* to OpenDSS files under *destination*.
59
+
60
+ Returns a dict mapping filename -> list of DSS command strings.
61
+ """
62
+ return cim_to_dss(network, destination)
63
+
64
+ # Conversion order: (CIM class, DSS output filename).
65
+ # Linecodes must come before Lines; Transformers before Regcontrols;
66
+ # switch Lines before their control devices.
67
+ EXPORT_ORDER: list[tuple[type, str]] = [
68
+ (cim.OverheadWireInfo, "WireData.dss"),
69
+ (cim.ConcentricNeutralCableInfo, "CNData.dss"),
70
+ (cim.TapeShieldCableInfo, "TSData.dss"),
71
+ (cim.ConductorDistanceSpacing, "LineSpacing.dss"),
72
+ (cim.WireSpacingInfo, "LineSpacing.dss"),
73
+ (cim.PerLengthPhaseImpedance, "Linecodes.dss"),
74
+ # Switches must precede Lines — they establish bus connectivity
75
+ (cim.LoadBreakSwitch, "Switches.dss"),
76
+ (cim.Fuse, "Switches.dss"),
77
+ (cim.Recloser, "Switches.dss"),
78
+ (cim.Breaker, "Switches.dss"),
79
+ (cim.ACLineSegment, "Lines.dss"),
80
+ (cim.PowerTransformer, "Transformers.dss"),
81
+ (cim.TransformerTank, "Transformers.dss"),
82
+ (cim.RatioTapChanger, "Regcontrols.dss"),
83
+ (cim.LinearShuntCompensator, "Capacitors.dss"),
84
+ (cim.RegulatingControl, "CapControls.dss"),
85
+ (cim.EnergyConsumer, "Loads.dss"),
86
+ (cim.EnergySource, "Vsources.dss"),
87
+ (cim.SeriesCompensator, "Reactors.dss"),
88
+ (cim.SynchronousMachine, "Generators.dss"),
89
+ (cim.PhotoVoltaicUnit, "PVSystems.dss"),
90
+ (cim.BatteryUnit, "Storage.dss"),
91
+ ]
92
+
93
+ # Legacy Pascal-era spelling — XML files in the wild use PhotoVoltaicUnit
94
+ _PhotoVoltaicUnit_legacy = getattr(cim, 'PhotoVoltaicUnit', None)
95
+ if _PhotoVoltaicUnit_legacy is not None and _PhotoVoltaicUnit_legacy is not cim.PhotoVoltaicUnit:
96
+ EXPORT_ORDER.append((_PhotoVoltaicUnit_legacy, "PVSystems.dss"))
97
+
98
+
99
+ def _convert_class(
100
+ cim_class: type,
101
+ network: FeederModel,
102
+ writer: DSSWriter,
103
+ ) -> list[str]:
104
+ """Convert all instances of a CIM class to DSS command strings.
105
+
106
+ Returns a list of DSS command strings (one per object, or two for
107
+ switch devices that return tuple[Line, ControlDevice]).
108
+ """
109
+ converter = dss_exporter_registry.get(cim_class)
110
+ if converter is None:
111
+ _log.warning(f"No converter registered for {cim_class.__name__}")
112
+ return []
113
+
114
+ commands: list[str] = []
115
+
116
+ try:
117
+ instances = network.graph.get(cim_class, {}).values()
118
+ except (AttributeError, TypeError):
119
+ return []
120
+
121
+ for obj in instances:
122
+ try:
123
+ result = converter(obj, network)
124
+ if result is None:
125
+ continue
126
+
127
+ # Converters may return:
128
+ # - a schema object (serialize via writer)
129
+ # - a tuple of schema objects (e.g. switches: Line + ControlDevice)
130
+ # - a tuple of raw strings (e.g. Vsource: Circuit + Edit)
131
+ if isinstance(result, tuple):
132
+ for item in result:
133
+ if isinstance(item, str):
134
+ commands.append(item)
135
+ else:
136
+ commands.append(writer.serialize(item))
137
+ elif isinstance(result, str):
138
+ commands.append(result)
139
+ else:
140
+ commands.append(writer.serialize(result))
141
+ except Exception as e:
142
+ _log.error(
143
+ f"Failed to convert {cim_class.__name__} '{getattr(obj, 'name', '?')}': {e}",
144
+ exc_info=True,
145
+ )
146
+
147
+ return commands
148
+
149
+
150
+ def _collect_voltage_bases(network: FeederModel) -> list[float]:
151
+ """Return a sorted-unique list of nominal kV values from all BaseVoltage objects."""
152
+ seen: set[float] = set()
153
+ for bv in network.graph.get(cim.BaseVoltage, {}).values():
154
+ try:
155
+ kv = round(bv.nominalVoltage.to('kV'), 6)
156
+ if kv > 0:
157
+ seen.add(kv)
158
+ except Exception:
159
+ pass
160
+ return sorted(seen, reverse=True)
161
+
162
+
163
+ def _circuit_name(network: FeederModel) -> str:
164
+ """Return a DSS-safe circuit name from the feeder model."""
165
+ name = getattr(network, 'container', None)
166
+ if name is not None:
167
+ name = getattr(name, 'name', None)
168
+ return str(name) if name else 'circuit'
169
+
170
+
171
+ def _new_circuit_line(vsource_commands: list[str]) -> str:
172
+ """Build the 'New Circuit' line from the first Vsource command.
173
+
174
+ 'New Circuit.name' implicitly creates a Vsource called 'source'.
175
+ All Vsource properties can be appended directly to that line,
176
+ so we strip the 'new Vsource.<name>' prefix and reuse the rest.
177
+ """
178
+ if not vsource_commands:
179
+ return 'New Circuit.circuit basekv=115.0'
180
+ # e.g. "new Vsource.source bus1=sourcebus basekv=115.0 pu=1.0 ..."
181
+ cmd = vsource_commands[0]
182
+ tokens = cmd.split()
183
+ # tokens[0]='new', tokens[1]='Vsource.source' — skip both
184
+ props = ' '.join(tokens[2:])
185
+ # Extract circuit name from the vsource name (Vsource.ieee13 -> ieee13)
186
+ vsource_name = tokens[1].split('.', 1)[-1] if '.' in tokens[1] else 'circuit'
187
+ return f'New Circuit.{vsource_name} {props}'
188
+
189
+
190
+ def _write_master(
191
+ output_path: Path,
192
+ new_circuit_line: str,
193
+ voltage_bases_kv: list[float],
194
+ filenames: list[str],
195
+ ) -> None:
196
+ """Write Master.dss with New Circuit definition and Redirect commands.
197
+
198
+ Vsources.dss is intentionally excluded from the redirect list because
199
+ 'New Circuit' already creates the Vsource with the properties inlined
200
+ on the New Circuit line.
201
+ """
202
+ bases_str = ' '.join(f'{v:.4g}' for v in sorted(voltage_bases_kv, reverse=True))
203
+ lines = ['Clear', '', new_circuit_line, '']
204
+ for filename in filenames:
205
+ lines.append(f'Redirect {filename}')
206
+ lines += ['', 'MakeBusList', f'Set VoltageBases=[{bases_str}]', 'CalcVoltageBases']
207
+
208
+ with open(output_path / 'Master.dss', 'w') as f:
209
+ f.write('\n'.join(lines) + '\n')
210
+
211
+
212
+ def cim_to_dss(
213
+ network: FeederModel,
214
+ output_dir: str | Path,
215
+ ) -> dict[str, list[str]]:
216
+ """Convert a CIM FeederModel to OpenDSS .dss files.
217
+
218
+ Iterates all registered CIM classes in dependency order, converts each
219
+ object to DSS schema dataclasses, serializes via DSSWriter, and writes
220
+ to per-component .dss files under ``output_dir``. Also writes a
221
+ ``Master.dss`` that creates the circuit and redirects all component files.
222
+
223
+ Args:
224
+ network: CIM network model (FeederModel).
225
+ output_dir: Directory path for output .dss files.
226
+
227
+ Returns:
228
+ Dictionary mapping filename -> list of DSS command strings written.
229
+ """
230
+ output_path = Path(output_dir)
231
+ output_path.mkdir(parents=True, exist_ok=True)
232
+
233
+ writer = DSSWriter()
234
+ all_commands: dict[str, list[str]] = {}
235
+
236
+ for cim_class, filename in EXPORT_ORDER:
237
+ commands = _convert_class(cim_class, network, writer)
238
+
239
+ if not commands:
240
+ continue
241
+
242
+ # Accumulate commands for files that receive multiple CIM classes
243
+ # (e.g. Transformers.dss gets both PowerTransformer and TransformerTank)
244
+ if filename in all_commands:
245
+ all_commands[filename].extend(commands)
246
+ else:
247
+ all_commands[filename] = commands
248
+
249
+ _log.info(
250
+ f"Converted {len(commands)} {cim_class.__name__} -> {filename}"
251
+ )
252
+
253
+ # Separate "Open Line.xxx 1" switch-state commands from switch definitions.
254
+ # These must run AFTER CalcVoltageBases so that voltage base propagation
255
+ # sees a fully-connected network (open switches break propagation paths and
256
+ # cause wrong kVBase assignment for isolated buses).
257
+ open_switch_cmds: list[str] = []
258
+ if "Switches.dss" in all_commands:
259
+ switch_defs = []
260
+ for cmd in all_commands["Switches.dss"]:
261
+ if cmd.strip().lower().startswith("open "):
262
+ open_switch_cmds.append(cmd)
263
+ else:
264
+ switch_defs.append(cmd)
265
+ all_commands["Switches.dss"] = switch_defs
266
+
267
+ # Write accumulated commands to files
268
+ for filename, commands in all_commands.items():
269
+ filepath = output_path / filename
270
+ with open(filepath, "w") as f:
271
+ for cmd in commands:
272
+ f.write(cmd + "\n")
273
+
274
+ # Generate Master.dss that redirects to all component files
275
+ _write_master_dss(output_path, all_commands, network, open_switch_cmds)
276
+
277
+ _log.info(
278
+ f"Export complete: wrote {len(all_commands)} files + Master.dss to {output_path}"
279
+ )
280
+
281
+ return all_commands
282
+
283
+
284
+ def _write_master_dss(
285
+ output_path: Path,
286
+ all_commands: dict[str, list[str]],
287
+ network: FeederModel | None = None,
288
+ open_switch_cmds: list[str] | None = None,
289
+ ) -> None:
290
+ """Generate Master.dss with Clear, Redirects, and Solve."""
291
+ import math
292
+
293
+ # Vsources must come first (creates the OpenDSS circuit)
294
+ ordered_files = []
295
+ seen: set[str] = set()
296
+ if "Vsources.dss" in all_commands:
297
+ ordered_files.append("Vsources.dss")
298
+ seen.add("Vsources.dss")
299
+ for _, filename in EXPORT_ORDER:
300
+ if filename in all_commands and filename not in seen:
301
+ ordered_files.append(filename)
302
+ seen.add(filename)
303
+
304
+ # Collect voltage bases only from transformer winding voltages and source voltages.
305
+ # Using all BaseVoltage objects would include L-N bus voltages (e.g. 7.2 kV = 12.47/√3)
306
+ # and equipment-rated voltages (e.g. 0.24 kV from PVsystems) which cause
307
+ # CalcVoltageBases to mis-assign buses.
308
+ vbases_raw: list[float] = []
309
+ if network is not None:
310
+ def _kv(voltage_obj) -> float:
311
+ if hasattr(voltage_obj, 'to'):
312
+ return float(voltage_obj.to('kV'))
313
+ return float(voltage_obj) / 1000.0
314
+
315
+ # System L-L voltages from transformer windings (PowerTransformerEnd.ratedU)
316
+ for end in network.graph.get(cim.PowerTransformerEnd, {}).values():
317
+ if end.ratedU is not None:
318
+ vbases_raw.append(_kv(end.ratedU))
319
+
320
+ # Single-phase transformer catalog voltage (ratedVoltage in CIM18, ratedU in CIM17).
321
+ # Values are L-L winding voltages stored in V (e.g. 12470 V, 240 V).
322
+ for info in network.graph.get(cim.TransformerEndInfo, {}).values():
323
+ v = getattr(info, "ratedVoltage", None) or getattr(info, "ratedU", None)
324
+ if v is not None:
325
+ vbases_raw.append(_kv(v))
326
+
327
+ # Split-phase / banked service transformers are modeled as TransformerTanks
328
+ # with no PowerTransformerEnd. Their winding voltage lives on each
329
+ # TransformerTankEnd.BaseVoltage (importer-assigned, already L-L, e.g. the
330
+ # 0.208 kV 120/240 V secondary). Without these the secondary buses have no
331
+ # matching candidate and CalcVoltageBases snaps them to the wrong base.
332
+ for te in network.graph.get(cim.TransformerTankEnd, {}).values():
333
+ bv = getattr(te, "BaseVoltage", None)
334
+ if bv is not None and bv.nominalVoltage is not None:
335
+ vbases_raw.append(_kv(bv.nominalVoltage))
336
+
337
+ # Source voltage
338
+ for src in network.graph.get(cim.EnergySource, {}).values():
339
+ if src.nominalVoltage is not None:
340
+ vbases_raw.append(_kv(src.nominalVoltage))
341
+
342
+ def _add_with_tolerance(values: list[float], tol: float = 0.005) -> set[float]:
343
+ """Deduplicate voltage values that are within tol fraction of each other."""
344
+ result: list[float] = []
345
+ for v in values:
346
+ if not any(abs(v - r) / (r + 1e-9) < tol for r in result):
347
+ result.append(v)
348
+ return set(result)
349
+
350
+ vbases_set = _add_with_tolerance(vbases_raw)
351
+
352
+ # Apply √3 filter: remove any voltage that is approximately V/√3 for another V
353
+ # already in the set (i.e. it is a phase-to-neutral value, not a system L-L voltage).
354
+ sqrt3 = math.sqrt(3)
355
+
356
+ def _is_ln_of_other(kv: float, all_kvs: set[float], tol: float = 0.015) -> bool:
357
+ for other in all_kvs:
358
+ if abs(kv - other / sqrt3) / (other + 1e-9) < tol:
359
+ return True
360
+ return False
361
+
362
+ vbases = sorted(
363
+ {kv for kv in vbases_set if not _is_ln_of_other(kv, vbases_set)},
364
+ reverse=True,
365
+ )
366
+
367
+ # Collect setkvbase overrides for buses that may be mis-assigned by CalcVoltageBases.
368
+ # This mirrors the explicit setkvbase commands in the original IEEE 9500 Master.dss.
369
+ # Buses at non-standard system voltages (e.g. 480V DER interconnection buses) are
370
+ # isolated from the main topology trace and need explicit kVBase assignment.
371
+ setkvbase_lines: list[str] = []
372
+ if network is not None:
373
+ # System L-L voltages that CalcVoltageBases handles correctly via topology tracing
374
+ traceable_kvs = set(vbases)
375
+
376
+ for node in network.graph.get(cim.ConnectivityNode, {}).values():
377
+ if node.BaseVoltage is None:
378
+ continue
379
+ node_kv = round(_kv(node.BaseVoltage.nominalVoltage), 4)
380
+ # Emit setkvbase for buses at voltages not directly traceable in the
381
+ # main topology (e.g. DER interconnection buses at 480V)
382
+ if node_kv not in traceable_kvs:
383
+ # Find closest traceable L-L voltage (the parent system voltage)
384
+ closest = min(traceable_kvs, key=lambda v: abs(v - node_kv * sqrt3))
385
+ if abs(node_kv - closest / sqrt3) / (closest + 1e-9) < 0.02:
386
+ # This is a L-N value of a traceable voltage — CalcVoltageBases
387
+ # handles this via the parent transformer, no override needed
388
+ continue
389
+ # Non-standard bus: emit setkvbase with its own kV (used as L-L)
390
+ setkvbase_lines.append(f"setkvbase {node.name} kVll={node_kv}")
391
+
392
+ lines = ["Clear"]
393
+ for filename in ordered_files:
394
+ lines.append(f"Redirect {filename}")
395
+ lines.append("")
396
+ if vbases:
397
+ vbases_str = ", ".join(str(round(v, 3)) for v in vbases)
398
+ lines.append(f"Set VoltageBases=[{vbases_str}]")
399
+ lines.append("CalcVoltageBases")
400
+ if setkvbase_lines:
401
+ lines.append("")
402
+ lines.extend(setkvbase_lines)
403
+ # Apply open-switch states AFTER CalcVoltageBases so that voltage base
404
+ # propagation sees a fully-connected network. Open switches break
405
+ # propagation paths and cause wrong kVBase for isolated end buses.
406
+ if open_switch_cmds:
407
+ lines.append("")
408
+ lines.extend(open_switch_cmds)
409
+ lines.append("Set MaxControlIter=100")
410
+ lines.append("Solve")
411
+ lines.append("")
412
+
413
+ master_path = output_path / "Master.dss"
414
+ master_path.write_text("\n".join(lines))
@@ -0,0 +1,17 @@
1
+ """Conductor and geometry exporters for CIM-to-DSS transformation."""
2
+
3
+ from cimhub_opendss.exporter.conductors.wiredata import convert_overhead_wire_info
4
+ from cimhub_opendss.exporter.conductors.cndata import convert_cn_cable_info
5
+ from cimhub_opendss.exporter.conductors.tsdata import convert_ts_cable_info
6
+ from cimhub_opendss.exporter.conductors.linespacing import convert_wire_spacing_info
7
+ from cimhub_opendss.exporter.conductors.conductor_distance_spacing import convert_conductor_distance_spacing
8
+ from cimhub_opendss.exporter.conductors.linegeometry import convert_line_geometry_result
9
+
10
+ __all__ = [
11
+ "convert_overhead_wire_info",
12
+ "convert_cn_cable_info",
13
+ "convert_ts_cable_info",
14
+ "convert_wire_spacing_info",
15
+ "convert_conductor_distance_spacing",
16
+ "convert_line_geometry_result",
17
+ ]