@@ -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
0 commit comments