Skip to content

Commit

Permalink
Merge branch 'master' of github.com:dpinney/omf
Browse files Browse the repository at this point in the history
  • Loading branch information
dpinney committed Nov 5, 2024
2 parents d2ce392 + 1df9783 commit 0b481ce
Show file tree
Hide file tree
Showing 6 changed files with 630 additions and 264 deletions.
72 changes: 72 additions & 0 deletions omf/models/gridlabMulti.html
Original file line number Diff line number Diff line change
Expand Up @@ -809,5 +809,77 @@
})
}
})

/**
* Take in two arrays as [A,B], return [[a1,b1],[a2,b2,],...]
*/
function zip(arrays) {
return arrays[0].map(function(_,i){
return arrays.map(function(array){return array[i]})
})
}

/**
* Group inL as compared by eqRel. Make sure the eqRel is an equivalence relation, or your brain will hurt.
*/
function partition(inL, eqRel) {
if (inL.length == 0) {return inL}
if (inL.length == 1) {return [inL]}
accum = []
work = [inL[0]]
for (i=1;i<inL.length;i++) {
if (eqRel(inL[i], work[0])) {
work.push(inL[i])
}
else {
accum.push(work)
work = [inL[i]]
}
}
accum.push(work)
return accum
}

/**
* Take [A1,A2,...An] and return an in-order list of the items in each Ai.
*/
function flatten1(matrix) {
accum = []
for (i=0;i<matrix.length;i++) {
if (typeof matrix[i] == 'object') {
for (j=0;j<matrix[i].length;j++) {
accum.push(matrix[i][j])
}
} else {
accum.push(matrix[i])
}
}
return accum
}

/**
* Get max of an array
*/
function arrMax(arr) {
return Math.max.apply(null,arr)
}

/**
* Sum an array.
*/
function arrSum(arr) {
return arr.reduce(function(x,y){return x+y})
}

/**
* Given an array of objects, return the first one where fun(arr[i]) is true.
*/
function indexFind(arr, fun) {
for (i=0;i<arr.length;i++) {
if (fun(arr[i])) {return i}
}
return -1
}

</script>
</body>
3 changes: 2 additions & 1 deletion omf/models/hostingCapacity.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ def run_ami_algorithm( modelDir, inputDict, outData ):
raise Exception(errorMessage)
AMI_end_time = time.time()

AMI_results = AMI_output[0].rename(columns={'kW_hostable': 'voltage_cap_kW'})
AMI_results = pd.read_csv( outputPath )
AMI_results.rename(columns={'kw_hostable': 'voltage_cap_kW'}, inplace=True)
histogramFigure = px.histogram( AMI_results, x='voltage_cap_kW', template="simple_white", color_discrete_sequence=["MediumPurple"] )
histogramFigure.update_layout(bargap=0.5)
# TBD - Needs to be modified when the MoHCA algorithm supports calculating thermal hosting capacity
Expand Down
25 changes: 14 additions & 11 deletions omf/solvers/mohca_cl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,20 @@ def sandia1(in_path, out_path):
ret_value = sandia.hosting_cap(in_path, out_path)
return ret_value

def sandia2(in_path, out_path):
return 'stub for lanl algo 2'

def gatech(in_path, out_path):
return 'stub for GA tech algo'

def iastate(in_path, out_path):
''' Execute Sandia hosting capacity algorithm on in_path CSV with output written as CSV to out_path. '''
ret_value = ISU_PINNbasedHCA.PINN_HC(in_path, out_path)
''' Execute ISU hosting capacity algorithm on in_path CSV with output written as CSV to out_path. '''
''' Besides the in_path and out_path, more setting information is needed for the code running. The information of the testing system is shown below.'''
input_csv_path = 'ISU_InputData_realsystem.csv' # input path
output_csv_path = 'Output_csv_path.csv' # output path
system_name = 'AMU_EC3' # system name for model saving
node_list_for_HC = [i for i in range(3)] # selected bus for HC analysis
total_bus_number = 50 # total bus number
model_retrain = 0 # 1 for retraining; 0 for not training
inverter_control_setting = 'var' # two setting mode: var prioirty and watt priority
inverter_advanced_control = 1 # 0->'without control' 1->'constant power factor' 2->'constant reactive power' 3->'active power-reactive power' 4->'voltage-reactive power'
ret_value = ISU_PINNbasedHCA.PINN_HC(system_name, input_csv_path, output_csv_path, total_bus_number, nodes_selected=node_list_for_HC, retrain_indicator=model_retrain, inverter_control=inverter_advanced_control, control_setting=inverter_control_setting)
#ret_value = ISU_PINNbasedHCA.PINN_HC(in_path, out_path)

return ret_value

def run_all_tests():
Expand All @@ -41,7 +46,5 @@ def init_cli():
'add': add,
'hello': hello,
'sandia1': sandia1,
'iastate': iastate,
'gatech': gatech,
'run_all_tests': run_all_tests
})
})
Loading

0 comments on commit 0b481ce

Please sign in to comment.