Skip to content

Commit

Permalink
Removed print statement and temporarily set multiprocessing = false t…
Browse files Browse the repository at this point in the history
…o fix output
  • Loading branch information
jenny-nyx committed May 29, 2024
1 parent 317c483 commit a5b1572
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions omf/models/hostingCapacity.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def createColorCSV(modelDir, df):
new_df = df[['bus','max_kw']]
new_df.to_csv(Path(modelDir, 'color_by.csv'), index=False)

def run_downline_load_algorithm( modelDir, inputDict, 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)
Expand Down Expand Up @@ -86,7 +86,7 @@ def run_downline_load_algorithm( modelDir, inputDict, outData):
outData['downline_runtime'] = convert_seconds_to_hms_ms( downline_end_time - downline_start_time )
return sorted_downlineDF

def run_ami_algorithm(modelDir, inputDict, outData):
def run_ami_algorithm( modelDir, inputDict, outData ):
# mohca data-driven hosting capacity
inputPath = Path(modelDir, inputDict['AMIDataFileName'])
inputAsString = inputPath.read_text()
Expand Down Expand Up @@ -130,18 +130,20 @@ def run_ami_algorithm(modelDir, inputDict, outData):
outData['AMI_tableValues'] = ( list(sorted_results.itertuples(index=False, name=None)) )
outData['AMI_runtime'] = convert_seconds_to_hms_ms( AMI_end_time - AMI_start_time )

def run_traditional_algorithm(modelDir, inputDict, outData):
def run_traditional_algorithm( modelDir, inputDict, outData ):
# traditional hosting capacity if they uploaded an omd circuit file and chose to use it.

# Check if the file was upploaded and checks to make sure the name matches
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, 'circuit.dss'))
traditional_start_time = time.time()
traditionalHCResults = opendss.hosting_capacity_all( FNAME = Path(modelDir, 'circuit.dss'), max_test_kw=int(inputDict["traditionalHCMaxTestkw"]), multiprocess=True)
traditionalHCResults = opendss.hosting_capacity_all( FNAME = Path(modelDir, 'circuit.dss'), max_test_kw=int(inputDict["traditionalHCMaxTestkw"]), multiprocess=False)
traditional_end_time = time.time()
# - opendss.hosting_capacity_all() changes the cwd, so change it back so other code isn't affected
tradHCDF = pd.DataFrame(traditionalHCResults)
tradHCDF = pd.DataFrame( traditionalHCResults )
sorted_tradHCDF = tradHCDF.sort_values(by='bus')
sorted_tradHCDF['plot_color'] = sorted_tradHCDF.apply ( lambda row: bar_chart_coloring(row), axis=1 )
# Plotly has its own colors - need to map the "name" of given colors to theirs
Expand Down
2 changes: 1 addition & 1 deletion omf/solvers/opendss/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ def hosting_capacity_single_bus(FILE_PATH:str, kwSTEPS:int, kwValue:float, BUS_N

def multiprocessor_function( FILE_PATH, max_test_kw, lock, BUS_NAME):
with lock:
print( "inside multiprocessor function" )
# print( "inside multiprocessor function" )
try:
single_output = get_hosting_capacity_of_single_bus_multiprocessing( FILE_PATH, BUS_NAME, max_test_kw, lock)
return single_output
Expand Down

0 comments on commit a5b1572

Please sign in to comment.