diff --git a/ditto/writers/opendss/write.py b/ditto/writers/opendss/write.py index 119422f4..fad6c768 100644 --- a/ditto/writers/opendss/write.py +++ b/ditto/writers/opendss/write.py @@ -13,6 +13,7 @@ import pandas as pd from functools import reduce +from functools import cmp_to_key # DiTTo imports from ditto.models.node import Node @@ -143,6 +144,41 @@ def float_to_str(self, f): d1 = ctx.create_decimal(repr(f)) return format(d1, "f") + def order_output(self,s1,s2): + """ Order the outputs as: + - wiredata + - CNDATA + - linegeometry + - linecodes + - lines + - transformers + - regulators + - loadshapes + - loads + - capacitors + """ + ordered_elements = ['wiredata','CNDATA','linegeometry','linecodes','lines','transformers','regulators','loadshapes','loads','capacitors','storage','PVSystems'] + for element_key in ordered_elements: + element = self.output_filenames[element_key] + if element in s1 and not element in s2: + return -1 + if element in s2 and not element in s1: + return 1 + if element in s1 and element in s2: + if s1