Skip to content

Commit 2dab396

Browse files
committed
Corrosion/creep/MG update #1/2:
- init_mod is a function in Mooring to initialize/reinitialize ss_mod. - effects of adjustPropertySets are permanent in the ss. - effects of creep/corrosion/MG are only effecting ss_mod. - we are currently modifying addMarineGrowth to enable cumulative effects of corrosion/creep/MG to take place while allowing the loop to happen within the Mooring object
1 parent fea61cd commit 2dab396

File tree

2 files changed

+71
-16
lines changed

2 files changed

+71
-16
lines changed

famodel/mooring/mooring.py

Lines changed: 64 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,14 @@ def __init__(self, dd=None, subsystem=None, anchor=None,
209209

210210
self.raftResults = {}
211211

212+
def init_mod(self):
213+
'''
214+
Initialize the modified subsystem (ss_mod) as a deep copy of the pristine subsystem (ss).
215+
'''
216+
if self.ss_mod is None and self.ss is not None:
217+
self.ss_mod = deepcopy(self.ss)
218+
self.dd_mod = deepcopy(self.dd)
219+
212220
def update(self, dd=None):
213221
'''Update the Mooring object based on the current state of the design
214222
dictionary (self.dd) or, if passed in, a new design dictionary (dd).
@@ -927,7 +935,12 @@ def addMarineGrowth(self, mgDict):
927935
# create a reference subsystem if it doesn't already exist
928936
if not self.ss:
929937
self.createSubsystem()
930-
oldLine = self.ss
938+
939+
if not self.ss_mod:
940+
oldLine = self.ss
941+
else:
942+
oldLine = self.ss_mod
943+
931944
# set up variables
932945
LTypes = [] # list of line types for new lines (types listed are from reference object)
933946
Lengths = [] # lengths of each section for new line
@@ -1091,8 +1104,9 @@ def addMarineGrowth(self, mgDict):
10911104
ndt = nd[j]['type']
10921105

10931106
# load in line props from MoorProps
1094-
opt = helpers.loadLineProps(None)
1095-
1107+
# opt = helpers.loadLineProps(None)
1108+
opt = self.lineProps
1109+
10961110
if 'd_nom' in st[ltyp]:
10971111
d_nom_old[j] = st[ltyp]['d_nom']
10981112
# get ratio between ve and nom diameter normally
@@ -1158,6 +1172,8 @@ def addMarineGrowth(self, mgDict):
11581172
ndt['EA'] = EA[j]
11591173
if 'EAd' in oldLine.lineTypes[ltyp]:
11601174
ndt['EAd'] = oldLine.lineTypes[ltyp]['EAd']
1175+
if 'EAd_Lm' in oldLine.lineTypes[ltyp]:
1176+
ndt['EAd_Lm'] = oldLine.lineTypes[ltyp]['EAd_Lm']
11611177
# add lengths
11621178
nd[j]['L'] = Lengths[j]
11631179

@@ -1167,7 +1183,11 @@ def addMarineGrowth(self, mgDict):
11671183
# self.connectorList = connList
11681184

11691185
# fill out rest of new design dictionary
1170-
nd1 = deepcopy(self.dd)
1186+
if self.ss_mod:
1187+
nd1 = deepcopy(self.dd_mod)
1188+
else:
1189+
nd1 = deepcopy(self.dd)
1190+
11711191
nd1['subcomponents'] = [None]*(len(nd)*2+1)
11721192
for i in range(len(nd)):
11731193
nd1['subcomponents'][2*i] = Connector('C'+str(i),**connList[i])
@@ -1185,8 +1205,9 @@ def addMarineGrowth(self, mgDict):
11851205

11861206
def addCorrosion(self, years=25, corrosion_rate=None, corrosion_mm=None):
11871207
'''
1188-
Calculates MBL of chain line with corrosion included
1189-
1208+
Reduces MBL of lines that have the 'corrosion_rate' feature in their MoorProps description (e.g. chain).
1209+
These changes take effect in the ss_mod subsystem.
1210+
11901211
Parameters
11911212
----------
11921213
years: float, optional
@@ -1195,11 +1216,16 @@ def addCorrosion(self, years=25, corrosion_rate=None, corrosion_mm=None):
11951216
Corrosion rate in mm/yr.
11961217
corrosion_mm : float, optional
11971218
Total corrosion in mm to apply directly.
1198-
If a corrosion_rate or a corrosion_mm are not given, the corrosion rate from the lineProps dictionary will be used.
1219+
Eirther corrosion_rate or corrosion_mm should be given. IF both are given, corrosion_rate is ignored and corrosion_mm will be used.
1220+
1221+
If neither corrosion_rate nor corrosion_mm are given, the corrosion rate from the lineProps dictionary will be used multiplied by the given years.
11991222
'''
12001223

1201-
if self.ss:
1202-
for i, line in enumerate(self.ss.lineList):
1224+
# initialize ss_mod if necessary
1225+
self.init_mod()
1226+
1227+
if self.ss_mod:
1228+
for i, line in enumerate(self.ss_mod.lineList):
12031229
# check if the line type has a corrosion property in its MoorProps instead of checking for material name.
12041230
mat = line.type['material']
12051231
if mat not in self.lineProps:
@@ -1214,10 +1240,14 @@ def addCorrosion(self, years=25, corrosion_rate=None, corrosion_mm=None):
12141240
corrosion_m = corrosion_mm / 1000 # convert to m
12151241
factor = ((line.type['d_nom'] - corrosion_m) / line.type['d_nom'])**2
12161242
line.type['MBL'] *= factor # update MBL with corrosion factored in
1243+
1244+
# Update dd_mod:
1245+
self.dd_mod['subcomponents'][self.i_sec[i][0]]['type']['MBL'] *= factor # assuming self.i_sec has not changed between pristine and modified designs.
12171246

12181247
def addCreep(self, years=25, creep_rate=None, creep=None):
12191248
'''
1220-
Elongates the polyester lines (if exists) in the mooring by a certain creep percentage
1249+
Elongates the lines that have the `creep_rate` feature in their MoorProps description (e.g. polyester).
1250+
These changes take effect in the ss_mod subsystem.
12211251
12221252
Parameters
12231253
----------
@@ -1227,10 +1257,20 @@ def addCreep(self, years=25, creep_rate=None, creep=None):
12271257
creep elongation rate [%]/yr to add to polyester lines.
12281258
creep : float, optional
12291259
Total creep elongation percent [%] to apply directly.
1230-
If a creep_rate and a creep are not given, the creep rate from the lineProps dictionary will be used with a given design life.
1260+
Either creep_rate or creep should be given. IF both are given, creep_rate is ignored and creep is used.
1261+
1262+
If neither creep_rate nor creep are given, the creep rate from the lineProps dictionary will be used multiplied by the given years.
12311263
'''
1232-
if self.ss:
1233-
for i, line in enumerate(self.ss.lineList):
1264+
# initialize ss_mod if necessary
1265+
self.init_mod()
1266+
1267+
# Make sure creep_rate or creep is given
1268+
if creep_rate and creep:
1269+
creep_rate = None
1270+
raise Warning('Both creep_rate and creep were given. Creep_rate will be ignored and creep will be used directly.')
1271+
1272+
if self.ss_mod:
1273+
for i, line in enumerate(self.ss_mod.lineList):
12341274
# check if the line type has a creep property in its MoorProps instead of checking for material name.
12351275
mat = line.type['material']
12361276
if mat not in self.lineProps:
@@ -1246,6 +1286,10 @@ def addCreep(self, years=25, creep_rate=None, creep=None):
12461286
L_creep = line.L * (1 + 0.01*creep)
12471287
#self.setSectionLength(L_creep, i)
12481288
line.setL(L_creep)
1289+
1290+
# Update dd_mod:
1291+
self.dd_mod['subcomponents'][self.i_sec[i][0]]['L'] = L_creep # assuming self.i_sec has not changed between pristine and modified designs.
1292+
12491293
'''
12501294
# Change the diameter size to account for creep thinning
12511295
d_nom_creep = line.type['d_nom'] / np.sqrt(1 + creep_percent)
@@ -1278,8 +1322,14 @@ def adjustPropertySets(self, suffix):
12781322
# Get and apply the modified properties
12791323
mat_suffix = mat + suffix # New material key to look for
12801324
if mat_suffix in self.lineProps:
1325+
# Get the new line properties
1326+
newType = getLineProps(sec['type']['d_nom']*1e3, mat_suffix, self.lineProps) # convert to mm for getLineProps
12811327
# Update the lineType properties in the Line in the MoorPy subsystem
1282-
line.type.update(getLineProps(sec['type']['d_nom']*1e3, mat_suffix, self.lineProps))
1328+
line.type.update(newType)
1329+
# Update the design dictionary
1330+
sec['type'].update(newType)
1331+
else:
1332+
raise ValueError('Mooring subsystem must be created before adjusting property sets.')
12831333

12841334

12851335
def getEnvelope(self,ang_spacing=45,SFs=True):

famodel/project.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3404,7 +3404,12 @@ def getRAFT(self,RAFTDict,pristine=1):
34043404
row.insert(IDindex, IDdata[i]) # Reinsert 'ID' data into each row
34053405
else:
34063406
raise Exception('Platform(s) must be specified in YAML file')
3407-
3407+
3408+
def updateState(self):
3409+
for moor in self.mooringList.values():
3410+
moor.addCorrosion()
3411+
moor.addCreep()
3412+
self.getMarineGrowth(lines={})
34083413
def getMarineGrowth(self,mgDict_list=None,buoy_mg=None, lines='all',tol=2,display=False):
34093414
'''Calls the addMarineGrowth mooring object method for the chosen mooring objects
34103415
and applies the specified marine growth thicknesses at the specified depth ranges
@@ -3538,7 +3543,7 @@ def getCorrosion(self, lineProps=None, corr_th=10, lines='all'):
35383543
idx = lines
35393544

35403545
for ii,i in enumerate(idx):
3541-
self.mooringList[i].addCorrosion(lineProps, corrosion_mm=corr_th)
3546+
self.mooringList[i].addCorrosion(corrosion_mm=corr_th)
35423547

35433548
def addCreep(self, lineProps=None, creep_percent=None):
35443549
'''

0 commit comments

Comments
 (0)