From 79065254de6a233b4ca677c332d4cfb4a5e939c7 Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 18 Mar 2024 10:37:46 -0400 Subject: [PATCH 1/2] Adds support for converting omd to networkx in dss_to_networkx. --- omf/solvers/opendss/dssConvert.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/omf/solvers/opendss/dssConvert.py b/omf/solvers/opendss/dssConvert.py index e93c17f9d..153e563a2 100644 --- a/omf/solvers/opendss/dssConvert.py +++ b/omf/solvers/opendss/dssConvert.py @@ -574,11 +574,12 @@ def omdToTree(omdFilePath): dss_tree = evilGldTreeToDssTree(evil_tree) return dss_tree -def dss_to_networkx(dssFilePath, tree=None): +def dss_to_networkx(dssFilePath, tree=None, omd=None): ''' Return a networkx directed graph from a dss file. If tree is provided, build graph from that instead of the file. ''' if tree == None: tree = dssToTree(dssFilePath) - omd = evilDssTreeToGldTree(tree) + if omd == None: + omd = evilDssTreeToGldTree(tree) # Gather edges, leave out source and circuit objects edges = [(ob['from'],ob['to']) for ob in omd.values() if 'from' in ob and 'to' in ob] edges_sub = [ From c7e5bd11fab397a2b02985566f6f5feb8a052d82 Mon Sep 17 00:00:00 2001 From: Lily Olson Date: Wed, 20 Mar 2024 09:36:16 -0400 Subject: [PATCH 2/2] additions to canonical dss order in opendss solver --- omf/solvers/opendss/dssConvert.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/omf/solvers/opendss/dssConvert.py b/omf/solvers/opendss/dssConvert.py index 153e563a2..d93d7440b 100644 --- a/omf/solvers/opendss/dssConvert.py +++ b/omf/solvers/opendss/dssConvert.py @@ -140,7 +140,7 @@ def dss_to_clean_via_save(dss_file, clean_out_path, add_pf_syntax=True, clean_up nice_buses = re.sub(r'([\w_\-\.]+),([\w_\-\.]+),([\w_\-\.]+)', r'setbusxy bus=\1 x=\2 y=\3', bus_data) clean_copies['buscoords.dss'] = 'makebuslist\n' + nice_buses #HACK: This is the order in which things need to be inserted or opendss errors out. Lame! Also note that pluralized things are from subfolders. - CANONICAL_DSS_ORDER = ['master.dss', 'loadshape.dss', 'vsource.dss', 'transformer.dss', 'transformers.dss', 'reactor.dss', 'regcontrol.dss', 'cndata.dss', 'wiredata.dss', 'linegeometry.dss', 'linecode.dss', 'spectrum.dss', 'swtcontrol.dss', 'tcc_curve.dss', 'capacitor.dss', 'capacitors.dss', 'growthshape.dss', 'line.dss', 'branches.dss', 'capcontrol.dss', 'generator.dss', 'pvsystem.dss', 'load.dss', 'loads.dss', 'energymeter.dss', 'monitor.dss', 'buscoords.dss', 'busvoltagebases.dss'] + CANONICAL_DSS_ORDER = ['master.dss', 'loadshape.dss', 'vsource.dss', 'transformer.dss', 'transformers.dss', 'reactor.dss', 'regcontrol.dss', 'cndata.dss', 'wiredata.dss', 'linegeometry.dss', 'linecode.dss', 'spectrum.dss', 'swtcontrol.dss', 'tcc_curve.dss', 'capacitor.dss', 'capacitors.dss', 'growthshape.dss', 'line.dss', 'branches.dss', 'capcontrol.dss', 'generator.dss', 'pvsystem.dss', 'load.dss', 'loads.dss', 'energymeter.dss', 'fault.dss', 'relay.dss', 'recloser.dss', 'fuse.dss', 'indmach012.dss', 'monitor.dss', 'buscoords.dss', 'busvoltagebases.dss'] # Note files we got that aren't in canonical files: for fname in clean_copies: if fname not in CANONICAL_DSS_ORDER: