Skip to content

Commit 6f150d8

Browse files
committed
setCorrosion, setCreep are now changing the subsystem. Bug fixes in LineDesign:
- Breaking the link between subcomponents and dd in CreateSubsystem - Fixing Update function in LineDesign so we update both dd and subsystem. - we set up corrosion and creep as absolute values by pulling from the nominal dd and applying changes to those. - other fixes
1 parent 2dab396 commit 6f150d8

File tree

4 files changed

+35
-56
lines changed

4 files changed

+35
-56
lines changed

famodel/design/LineDesign.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,9 +605,11 @@ def updateDesign(self, X, display=0, display2=0, normalized=True):
605605
name=i, lineProps=self.lineProps)
606606
# use the update method to preserve refs to the original dict - this 'points'/connects to the subsystem object too!
607607
self.dd['subcomponents'][2*i+1]['type'].update(lineType)
608-
608+
# update the ss as well
609+
self.ss.lineList[i].type.update(lineType)
610+
609611
# apply corrosion to the mooring's MBL dictionary (which gets references in the getTenSF constraint in subsystem)
610-
self.addCorrosion(corrosion_mm=self.corrosion_mm)
612+
self.setCorrosion(corrosion_mm=self.corrosion_mm)
611613

612614
# update the intermediate points if they have any weight or buoyancy
613615
for i in range(self.nLines-1):

famodel/mooring/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,11 @@ Re-creates sections part of design dictionary to account for marine growth on th
110110

111111

112112

113-
### addCorrosion
114-
Calculates MBL of chain line with corrosion included
113+
### setCorrosion
114+
Calculates MBL of chain line with corrosion included for those lines that have a corrosion_rate feature in their MoorProps dictionary.
115+
116+
### setCreep
117+
Elongates the length of a line that has a creep_rate feature in its MoorProps dictionary.
115118

116119
### getEnvelope
117120
Computes the motion envelope of the Mooring based on the watch

famodel/mooring/mooring.py

Lines changed: 25 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,6 @@ def __init__(self, dd=None, subsystem=None, anchor=None,
208208
}
209209

210210
self.raftResults = {}
211-
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)
219211

220212
def update(self, dd=None):
221213
'''Update the Mooring object based on the current state of the design
@@ -620,7 +612,7 @@ def createSubsystem(self, case=0, pristine=True, dd=None, ms=None):
620612
# run through each line section and collect the length and type
621613
for sec in secs:
622614
lengths.append(sec['L'])
623-
types.append(sec['type']) # list of type names
615+
types.append(deepcopy(sec['type'])) # list of type names
624616

625617

626618
# make the lines and set the points
@@ -892,11 +884,11 @@ def updateState(self, stateDict):
892884

893885
# 2. Apply creep if specified
894886
if stateDict.get('creep', False):
895-
self.addCreep(years)
887+
self.setCreep(years)
896888

897889
# 3. Apply corrosion if specified
898890
if stateDict.get('corrosion', False):
899-
self.addCorrosion(years)
891+
self.setCorrosion(years)
900892

901893
# 4. Apply marine growth if specified
902894
if 'marineGrowth' in stateDict:
@@ -936,10 +928,7 @@ def addMarineGrowth(self, mgDict):
936928
if not self.ss:
937929
self.createSubsystem()
938930

939-
if not self.ss_mod:
940-
oldLine = self.ss
941-
else:
942-
oldLine = self.ss_mod
931+
oldLine = self.ss
943932

944933
# set up variables
945934
LTypes = [] # list of line types for new lines (types listed are from reference object)
@@ -1183,10 +1172,7 @@ def addMarineGrowth(self, mgDict):
11831172
# self.connectorList = connList
11841173

11851174
# fill out rest of new design dictionary
1186-
if self.ss_mod:
1187-
nd1 = deepcopy(self.dd_mod)
1188-
else:
1189-
nd1 = deepcopy(self.dd)
1175+
nd1 = deepcopy(self.dd)
11901176

11911177
nd1['subcomponents'] = [None]*(len(nd)*2+1)
11921178
for i in range(len(nd)):
@@ -1203,10 +1189,10 @@ def addMarineGrowth(self, mgDict):
12031189
return(changeDepths,changePoints)
12041190

12051191

1206-
def addCorrosion(self, years=25, corrosion_rate=None, corrosion_mm=None):
1192+
def setCorrosion(self, years=25, corrosion_rate=None, corrosion_mm=None):
12071193
'''
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.
1194+
Reduces MBL of lines that have the 'corrosion_rate' feature in
1195+
their MoorProps description (e.g. chain).
12101196
12111197
Parameters
12121198
----------
@@ -1221,13 +1207,13 @@ def addCorrosion(self, years=25, corrosion_rate=None, corrosion_mm=None):
12211207
If neither corrosion_rate nor corrosion_mm are given, the corrosion rate from the lineProps dictionary will be used multiplied by the given years.
12221208
'''
12231209

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):
1210+
if self.ss:
1211+
for i, line in enumerate(self.ss.lineList):
12291212
# check if the line type has a corrosion property in its MoorProps instead of checking for material name.
1230-
mat = line.type['material']
1213+
sec = self.getSubcomponent(self.i_sec[i])
1214+
mat = sec['type']['material']
1215+
d_nom = sec['type']['d_nom']
1216+
mbl = sec['type']['MBL']
12311217
if mat not in self.lineProps:
12321218
raise ValueError(f'Line material {mat} not found in lineProps dictionary.')
12331219
else:
@@ -1238,16 +1224,14 @@ def addCorrosion(self, years=25, corrosion_rate=None, corrosion_mm=None):
12381224
corrosion_mm = corrosion_rate * years # total corrosion over design life in mm
12391225

12401226
corrosion_m = corrosion_mm / 1000 # convert to m
1241-
factor = ((line.type['d_nom'] - corrosion_m) / line.type['d_nom'])**2
1242-
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.
1227+
factor = ((d_nom - corrosion_m) / d_nom)**2
1228+
new_mbl = mbl * factor
1229+
line.type['MBL'] = new_mbl # update MBL with corrosion factored in
1230+
12461231

1247-
def addCreep(self, years=25, creep_rate=None, creep=None):
1232+
def setCreep(self, years=25, creep_rate=None, creep=None):
12481233
'''
12491234
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.
12511235
12521236
Parameters
12531237
----------
@@ -1261,18 +1245,18 @@ def addCreep(self, years=25, creep_rate=None, creep=None):
12611245
12621246
If neither creep_rate nor creep are given, the creep rate from the lineProps dictionary will be used multiplied by the given years.
12631247
'''
1264-
# initialize ss_mod if necessary
1265-
self.init_mod()
12661248

12671249
# Make sure creep_rate or creep is given
12681250
if creep_rate and creep:
12691251
creep_rate = None
12701252
raise Warning('Both creep_rate and creep were given. Creep_rate will be ignored and creep will be used directly.')
12711253

1272-
if self.ss_mod:
1273-
for i, line in enumerate(self.ss_mod.lineList):
1254+
if self.ss:
1255+
for i, line in enumerate(self.ss.lineList):
1256+
sec = self.getSubcomponent(self.i_sec[i])
1257+
mat = sec['type']['material']
1258+
lgt = sec['L']
12741259
# check if the line type has a creep property in its MoorProps instead of checking for material name.
1275-
mat = line.type['material']
12761260
if mat not in self.lineProps:
12771261
raise ValueError(f'Line material {mat} not found in lineProps dictionary.')
12781262
else:
@@ -1283,13 +1267,10 @@ def addCreep(self, years=25, creep_rate=None, creep=None):
12831267
if not creep:
12841268
creep = creep_rate * years # total creep percent over design life
12851269

1286-
L_creep = line.L * (1 + 0.01*creep)
1270+
L_creep = lgt * (1 + 0.01*creep)
12871271
#self.setSectionLength(L_creep, i)
12881272
line.setL(L_creep)
12891273

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-
12931274
'''
12941275
# Change the diameter size to account for creep thinning
12951276
d_nom_creep = line.type['d_nom'] / np.sqrt(1 + creep_percent)
@@ -1326,8 +1307,6 @@ def adjustPropertySets(self, suffix):
13261307
newType = getLineProps(sec['type']['d_nom']*1e3, mat_suffix, self.lineProps) # convert to mm for getLineProps
13271308
# Update the lineType properties in the Line in the MoorPy subsystem
13281309
line.type.update(newType)
1329-
# Update the design dictionary
1330-
sec['type'].update(newType)
13311310
else:
13321311
raise ValueError('Mooring subsystem must be created before adjusting property sets.')
13331312

famodel/project.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3405,11 +3405,6 @@ def getRAFT(self,RAFTDict,pristine=1):
34053405
else:
34063406
raise Exception('Platform(s) must be specified in YAML file')
34073407

3408-
def updateState(self):
3409-
for moor in self.mooringList.values():
3410-
moor.addCorrosion()
3411-
moor.addCreep()
3412-
self.getMarineGrowth(lines={})
34133408
def getMarineGrowth(self,mgDict_list=None,buoy_mg=None, lines='all',tol=2,display=False):
34143409
'''Calls the addMarineGrowth mooring object method for the chosen mooring objects
34153410
and applies the specified marine growth thicknesses at the specified depth ranges
@@ -3543,7 +3538,7 @@ def getCorrosion(self, lineProps=None, corr_th=10, lines='all'):
35433538
idx = lines
35443539

35453540
for ii,i in enumerate(idx):
3546-
self.mooringList[i].addCorrosion(corrosion_mm=corr_th)
3541+
self.mooringList[i].setCorrosion(corrosion_mm=corr_th)
35473542

35483543
def addCreep(self, lineProps=None, creep_percent=None):
35493544
'''

0 commit comments

Comments
 (0)