Skip to content

Commit faaed56

Browse files
committed
Corrosion/creep/MG updated #2/2
-- update marine growth to work with state process - mooring.addMarineGrowth() now contains while loop to adjust change depths for settling instead of project.getMarineGrowth -- added mooring.applied_states dictionary which lists the applied states as keys (i.e. marine_growth, corrosion) and the settings for these states as values (i.e. mg dict list) -- add mooring.reset() to reset the mooring.ss to pristine values and clear the applied_states property -- update tests and examples to not use ss_mod -- add reset() at beginning of updateDesign in lineDesign to clear out any corrosion etc applied in previous iterations -- removed while loop from project.getMarineGrowth() since this is now done in the cable and mooring methdos -- added dynamicCable.applied_states similar to mooring, but only key currently is 'marine_growth'
1 parent 6f150d8 commit faaed56

File tree

6 files changed

+417
-380
lines changed

6 files changed

+417
-380
lines changed

examples/example_driver.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from famodel.project import Project
2222
import os
2323
import matplotlib.pyplot as plt
24+
from copy import deepcopy
2425

2526
# set yaml file location and name
2627
dir = os.path.dirname(os.path.realpath(__file__))
@@ -32,7 +33,7 @@
3233
# create project object
3334
project = Project(file=ontology_file, raft=False)
3435
# create moorpy system of the array, include cables in the system
35-
project.getMoorPyArray(cables=True)
36+
project.getMoorPyArray()
3637
# plot in 3d, using moorpy system for the mooring and cable plots
3738
project.plot2d()
3839
project.plot3d()
@@ -102,11 +103,12 @@
102103
#### add marine growth to the mooring lines and cables ####
103104
print('\nAdding marine growth\n')
104105
# marine growth dictionary is read in from YAML, see Ontology ReadMe for description
106+
reg_line_d = deepcopy(project.mooringList['FOWT1a'].ss.lineList[1].type['d_nom'])
105107
project.getMarineGrowth(display=False)
106108
# moorpy system lines with marine growth are stored in the respective objects under ss_mod (pristine lines are stored under ss)
107109
# check the difference in nominal diameter for a given line:
108-
reg_line_d = project.mooringList['FOWT1a'].ss.lineList[1].type['d_nom']
109-
mg_line_d = project.mooringList['FOWT1a'].ss_mod.lineList[-1].type['d_nom']
110+
mg_line_d = project.mooringList['FOWT1a'].ss.lineList[-1].type['d_nom']
111+
110112
print('\nPristine line polyester nominal diameter just below surface: ',reg_line_d)
111113
print('Marine growth line polyester nominal diameter just below surface: ',mg_line_d)
112114

famodel/cables/dynamic_cable.py

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ def __init__(self, id, dd=None, subsystem=None, rA=[0,0,0], rB=[0,0,0],
113113
# alternate designs to interpolate between when depth changes
114114
self.alternate_designs = None
115115

116+
# dict of states applied to this Cable object subsystem
117+
self.applied_states = {'marine_growth':None}
118+
116119
# Dictionaries for addition information
117120
self.loads = {}
118121
self.safety_factors = {} # calculated safety factor
@@ -121,6 +124,7 @@ def __init__(self, id, dd=None, subsystem=None, rA=[0,0,0], rB=[0,0,0],
121124
self.cost = {}
122125
self.failure_probability = {}
123126

127+
124128

125129
def makeCableType(self,cabDict):
126130
'''
@@ -437,7 +441,7 @@ def updateTensions(self):
437441

438442
return(self.loads['TAmax'],self.loads['TBmax'])
439443

440-
def createSubsystem(self, case=0,pristine=True,dd=None):
444+
def createSubsystem(self, case=0, dd=None):
441445
''' Creates a subsystem for cable and buoyancy section(s) configuration from the design dictionary
442446
443447
Parameters
@@ -472,12 +476,12 @@ def createSubsystem(self, case=0,pristine=True,dd=None):
472476
# If no buoyancy sections, it's just one section of the bare cable
473477
if not 'buoyancy_sections' in dd or not dd['buoyancy_sections']:
474478
#self.dd['sections'].append({'type':self.cableType,'length':self.L})
475-
types.append(cableType)
479+
types.append(deepcopy(cableType))
476480
lengths.append(self.L)
477481

478482
if 'sections' in dd and dd['sections']: # this will be the case for marine growth or possibly other cases
479483
for i, sec in enumerate(dd['sections']):
480-
types.append(sec['type'])
484+
types.append(deepcopy(sec['type']))
481485
lengths.append(sec['length'])
482486
elif 'buoyancy_sections' in dd:
483487
# Parse buoyancy sections to compute their properties and all lengths
@@ -609,14 +613,12 @@ def createSubsystem(self, case=0,pristine=True,dd=None):
609613

610614

611615
# save it in the object
612-
if pristine:
613-
self.ss = ss
614-
return(self.ss)
615-
else:
616-
self.ss_mod = ss
617-
return(self.ss_mod)
616+
self.ss = ss
617+
return(self.ss)
618618

619-
def addMarineGrowth(self, mgDict, buoy_mg, updateDepths=False,tol=2):
619+
def addMarineGrowth(self, mgDict, buoy_mg,
620+
updateDepths=False, tol=2,
621+
starting_ss=None, display=False):
620622
'''Creates a new design dictionary (does not overwrite old one) to account for marine
621623
growth on the subystem, then calls createSubsystem() to recreate the cable
622624
@@ -647,12 +649,11 @@ def addMarineGrowth(self, mgDict, buoy_mg, updateDepths=False,tol=2):
647649
List of cutoff depths the changePoints should be located at
648650
649651
'''
650-
def getMG(mgDict, buoy_mg):
652+
def getMG(mgDict, buoy_mg, oldLine=None):
651653
# create a reference subsystem if it doesn't already exist
652-
if not self.ss:
653-
self.createSubsystem(pristine=1)
654-
# set location of reference subsystem
655-
oldLine = self.ss
654+
if not oldLine:
655+
oldLine = self.createSubsystem(pristine=1)
656+
656657
# set up variables
657658
LTypes = [] # list of line types for new lines (types listed are from reference object)
658659
Lengths = [] # lengths of each section for new line
@@ -940,22 +941,27 @@ def getMG(mgDict, buoy_mg):
940941

941942
# call createSubsystem() to make moorpy subsystem with marine growth
942943
if self.shared>0:
943-
self.createSubsystem(case=int(self.shared),dd=nd1,pristine=0)
944+
self.createSubsystem(case=int(self.shared),dd=nd1)
944945
else:
945-
self.createSubsystem(dd=nd1,pristine=0)
946+
self.createSubsystem(dd=nd1)
946947

947948
return(changeDepths,changePoints)
948949

949950
############################################################################################################################
951+
if starting_ss:
952+
ss = deepcopy(starting_ss)
953+
else:
954+
ss = deepcopy(self.ss)
955+
950956
if updateDepths:
951957
mgDict1 = deepcopy(mgDict)
952958
cEq = tol + 1
953959
ct = 0
954960
while(cEq>tol):
955-
changeDepths,changePoints = getMG(mgDict1, buoy_mg)
961+
changeDepths,changePoints = getMG(mgDict1, buoy_mg, oldLine=ss)
956962
D = []
957963
for d in range(0,len(changeDepths)):
958-
diff = mgDict[changeDepths[d][0]][changeDepths[d][1]] - self.ss_mod.pointList[changePoints[d]].r[2]
964+
diff = mgDict[changeDepths[d][0]][changeDepths[d][1]] - self.ss.pointList[changePoints[d]].r[2]
959965
D.append(diff)
960966
cEq = np.mean(D)
961967
# adjust depth to change based on difference between actual and desired change depth
@@ -968,14 +974,17 @@ def getMG(mgDict, buoy_mg):
968974
elif (ct >= 4 and ct < 9) or abs(cEq)>=12:
969975
# could be ping-ponging between two different things, try adding half
970976
mgDict1[j][k] = mgDict1[j][k] + 0.5*cEq
971-
print('average difference between expected and actual change depth is: ',cEq)
977+
if display == True:
978+
print('average difference between expected and actual change depth is: ',cEq)
972979
if ct > 10:
973980
print('Could not meet tolerance in 10 attempts. Exiting loop')
974981
break
975982
ct += 1
976983
else:
977-
changeDepths,changePoints = getMG(mgDict, buoy_mg)
978-
return(changeDepths,changePoints)
984+
changeDepths,changePoints = getMG(mgDict, buoy_mg, oldLine=ss)
985+
986+
self.applied_states['marine_growth'] = mgDict
987+
return(changeDepths,changePoints)
979988

980989

981990

famodel/design/LineDesign.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,9 @@ def updateDesign(self, X, display=0, display2=0, normalized=True):
519519
'''
520520
start_time = time.time()
521521

522+
# reset modifiers to mooring design (corrosion/creep/marine_growth)
523+
self.reset()
524+
522525
# Design vector error checks
523526
if len(X)==0: # if any empty design vector is passed (useful for checking constraints quickly)
524527
return

0 commit comments

Comments
 (0)