Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/dpinney/omf
Browse files Browse the repository at this point in the history
  • Loading branch information
jenny-nyx committed Mar 21, 2024
2 parents 3c45fab + c7e5bd1 commit e09a238
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions omf/solvers/opendss/dssConvert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 = [
Expand Down

0 comments on commit e09a238

Please sign in to comment.