Skip to content

Commit

Permalink
Cleaned up unnecessary function in hosting capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
jenny-nyx committed Apr 23, 2024
1 parent 78055d1 commit dff03f4
Showing 1 changed file with 15 additions and 26 deletions.
41 changes: 15 additions & 26 deletions omf/models/hostingCapacity.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,8 @@ def bar_chart_coloring( row ):
def createColorCSV(modelDir, df):
new_df = df[['bus','max_kw']]
new_df.to_csv(Path(modelDir, 'color_by.csv'), index=False)

def my_GetCoords(dssFilePath):
'''Takes in an OpenDSS circuit definition file and outputs the bus coordinates as a dataframe.'''
dssFileLoc = os.path.dirname(dssFilePath)
curr_dir = os.getcwd()
opendss.runDSS(dssFilePath)
opendss.runDssCommand(f'export buscoords "{curr_dir}/coords.csv"')
coords = pd.read_csv(curr_dir + '/coords.csv', header=None)
# JENNY - Deleted Radius and everything after.
coords.columns = ['Element', 'X', 'Y']
return coords

def omd_to_nx( dssFilePath, tree=None ):
def omd_to_nx_fulldata( dssFilePath, tree=None ):
''' Combines dss_to_networkX and opendss.networkPlot together.
Creates a networkx directed graph from a dss files. If a tree is provided, build graph from that instead of the file.
Expand Down Expand Up @@ -139,27 +128,14 @@ def omd_to_nx( dssFilePath, tree=None ):

return [G, pos, labels]

def work(modelDir, inputDict):
outData = {}

if inputDict['runAmiAlgorithm'] == 'on':
run_ami_algorithm(modelDir, inputDict, outData)
if inputDict.get('optionalCircuitFile', outData) == 'on':
run_traditional_algorithm(modelDir, inputDict, outData)
if inputDict.get('runDownlineAlgorithm') == 'on':
run_downline_load_algorithm( modelDir, inputDict, outData)
outData['stdout'] = "Success"
outData['stderr'] = ""
return outData

def run_downline_load_algorithm( modelDir, inputDict, outData):
feederName = [x for x in os.listdir(modelDir) if x.endswith('.omd') and x[:-4] == inputDict['feederName1'] ][0]
inputDict['feederName1'] = feederName[:-4]
path_to_omd = Path(modelDir, feederName)
tree = opendss.dssConvert.omdToTree(path_to_omd)
opendss.dssConvert.treeToDss(tree, Path(modelDir, 'downlineLoad.dss'))
downline_start_time = time.time()
graphData = omd_to_nx( os.path.join( modelDir, 'downlineLoad.dss') )
graphData = omd_to_nx_fulldata( os.path.join( modelDir, 'downlineLoad.dss') )
graph = graphData[0]
buses = opendss.get_all_buses( os.path.join( modelDir, 'downlineLoad.dss') )
buses_output = {}
Expand Down Expand Up @@ -290,6 +266,19 @@ def runtimeEstimate(modelDir):
''' Estimated runtime of model in minutes. '''
return 1.0

def work(modelDir, inputDict):
outData = {}

if inputDict['runAmiAlgorithm'] == 'on':
run_ami_algorithm(modelDir, inputDict, outData)
if inputDict.get('optionalCircuitFile', outData) == 'on':
run_traditional_algorithm(modelDir, inputDict, outData)
if inputDict.get('runDownlineAlgorithm') == 'on':
run_downline_load_algorithm( modelDir, inputDict, outData)
outData['stdout'] = "Success"
outData['stderr'] = ""
return outData

def new(modelDir):
''' Create a new instance of this model. Returns true on success, false on failure. '''
meter_file_name = 'mohcaInputCustom.csv'
Expand Down

0 comments on commit dff03f4

Please sign in to comment.