Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d74f558
Add failure calculation files
EmmaSlackGraph Jun 4, 2024
171e392
Add Excel spreadsheets
EmmaSlackGraph Jun 5, 2024
8b58adf
Add failure folder
EmmaSlackGraph Jun 6, 2024
08a57d7
Add subnode and subedge failures + fix clashing failure nodes
EmmaSlackGraph Jun 6, 2024
e04a1b3
Update failure files
EmmaSlackGraph Jun 6, 2024
e21ee68
Remove files after putting into failure folder
EmmaSlackGraph Jun 6, 2024
13e9b6e
Mooring edits for smoother connector information, and a few other things
mattEhall Jun 5, 2024
b970fff
Update Readme, add failure probability dictionaries
lsirkis Jun 6, 2024
bdd3552
Same as previous commit with turbine failure prob added
lsirkis Jun 6, 2024
e1bdfdd
Same as previous commit with Mooring failure probability dict added
lsirkis Jun 6, 2024
e5b3c1a
Minor fix to ontology Readme
lsirkis Jun 6, 2024
5f9d21b
Remove redundancies in mooring
lsirkis Jun 6, 2024
0829b6d
Small fix to mooring line inputs
lsirkis Jun 6, 2024
a0828ec
New code for drilled and grout piles in (weak) rock following the loc…
Jun 6, 2024
d122ed8
Convert to failureGraph class and comment functions
EmmaSlackGraph Jun 6, 2024
83d9040
Add methods for updating the critical failures after original critica…
EmmaSlackGraph Jun 10, 2024
c7c1cbd
Initialize method to enact failures (still work in progress)
EmmaSlackGraph Jun 10, 2024
6924bad
Change enact function
EmmaSlackGraph Jun 12, 2024
222714d
Mooring update for Subsystem "span" update and including rA, rB defaults
mattEhall Jun 6, 2024
50cd49f
Allow creation of Mooring object with subsystem instead of dd
lsirkis Jun 6, 2024
324ca67
Remove breakpoint in mooring.py
lsirkis Jun 6, 2024
7bd1b2a
Minor mooring.py debug
lsirkis Jun 7, 2024
84f5f87
Platform setPosition allow send in of project class instance
lsirkis Jun 7, 2024
7a3e040
Add failure_probabilitites dict to Section class in connector.py
EmmaSlackGraph Jun 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added failure/failureData.xlsx
Binary file not shown.
741 changes: 741 additions & 0 deletions failure/failureProbabilities.py

Large diffs are not rendered by default.

Binary file added failure/failureProbabilities.xlsx
Binary file not shown.
488 changes: 488 additions & 0 deletions failure/graphBuilder.py

Large diffs are not rendered by default.

429 changes: 429 additions & 0 deletions failure/searchMethods.py

Large diffs are not rendered by default.

76 changes: 76 additions & 0 deletions failure/twoTurbineCaseStudy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import numpy as np
from failure.graphBuilder import *
from failure.searchMethods import *

''' twoTurbineCaseStudy.py -----------------------------------------------------------------------------------------------

****************************** Last Updated: 18 April 2024 ******************************

Methods:
1) twoTurbine_bayesian_table: input adjusted adjacency matrix, adjacency matrix, current node, list of node names,
adjusted list of node names --> outputs list of parents, probability table

-----------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------


twoTurbine_bayesian_table Documentation
------------------------------------------
This method inputs an adjusted adjacency matrix, regular adjacency matrix, current node (integer), array of node names (strings),
and adjusted node names (same indexing as adjusted adjacency matrix). We then calculate the probability table for the current node
given its parents in the adjusted adjacency matrix. We use the weights from the regular adjacency matrix to determine the transitional
probabilities between nodes. We output an array of the current node's parents and its probability table.'''


def twoTurbine_bayesian_table(a, arr, current, nodeNames, non):
# arr, nodeNames = excel2Matrix("ExcelFiles/failureData.xlsx", "twoTurbines_simplified") # For debugging, feel free to uncomment
adj = a.copy()
nodes = diagonal_nodes(adj) # Diagonal matrix of node's numerical names +1
adj = make_binary(adj, 0) # Binarize adjacency matrix
parents_bool = nodes @ adj[:, current-1] # vector of zeros and parent names (numerical names)
parents = list(parents_bool[np.nonzero(parents_bool)]) # list of just the parent names (numerical names)
prob_table = np.zeros((2 ** len(parents), len(parents) + 2)) # Initialize the array for the node's conditional probability distribution

current_index = np.where(nodeNames == non[int(current - 1)])[0][0]

for iteration in range(2 ** len(parents)): # For each combination of parents having either failed or not
true_false_array = [] # Iniitalize to record which parents have failed

for p in range(len(parents)):
parent_index = np.where(nodeNames == non[int(parents[p] - 1)])[0][0]
prob_table[iteration][p] = int(iteration / (2 ** p)) % 2 # Append whether or not the parent node has failed
prob_table[iteration][-2] += (1- int(iteration / (2 ** p)) % 2) * arr[parent_index][current_index] # Determine parent probability (given if the parent has failed or not)
true_false_array.append((int(iteration / (2 ** p)) % 2)) # Append whether or not the parent node has failed

if prob_table[iteration][-2] > 1: # If the value is greater than 1, set the probability to 1
prob_table[iteration][-2] = 1
prob_table[iteration][-1] = 1 - prob_table[iteration][-2] # Add the probability of the node not failing to the array
# print(prob_table)
return parents, prob_table



'''
# The following code is for writing excel file with all pair-wise probabilities. To run, copy and paste the code below into main.py and hit 'Run.'

adjacency_matrix, nodeNames = excel2Matrix("ExcelFiles/failureData.xlsx", "twoTurbines_simplified")
current = 1
midpoint = True
num_iterations = 1
probabilities, nodeNames = getProbabilities("ExcelFiles/failureProbabilities.xlsx", sheetName = "Conditional Probabilities (2)")
all_probs = np.zeros(adjacency_matrix.shape)
with pd.ExcelWriter("bayesian_simulations3.xlsx") as writer:
for i in range(1, len(nodeNames) + 1):
print("----------------------------------", i, "----------------------------------")
array_of_probs = np.zeros((len(nodeNames), 2))
for j in range(1,len(nodeNames)+1):
adjacency_matrix2 = adjacency_matrix.copy()
probabilities = np.array(probabilities).copy()
A, B = backward_bayesian_inference(adjacency_matrix2, nodeNames, [i], [i], [j], probabilities, start_bool = True, multi = False, poc="child", twoTurbine = True)
array_of_probs[j-1] = A
df = pd.DataFrame(np.array(array_of_probs))
df.to_excel(writer, sheet_name="Probabilities given "+str(i))
all_probs[:,i-1] = array_of_probs[:,0]
df2 = pd.DataFrame(np.array(all_probs))
df2.to_excel(writer, sheet_name="allProbs")
'''
Loading