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