@@ -479,15 +479,18 @@ def createSubsystem(self, case=0, pristine=True, dd=None, ms=None):
479479 dd : dict, optional
480480 Dictionary describing the design
481481 ms : MoorPy System, optional
482- MoorPy system this subsystem is a part of
482+ MoorPy system this subsystem is a part of. Necessary if
483483 '''
484- # TODO: Figure out how to handle subsystems for lines with subsections (esp when double chain in middle...)
484+
485485 # set design dictionary as self.dd if none given, same with connectorList
486486 if not dd :
487487 dd = self .dd
488488
489489 if self .parallels : # make parts of a MoorPy system
490490
491+ if not ms :
492+ raise Exception ('A MoorPy system (ms) must be provided for a Mooring with parallel/bridle parts.' )
493+
491494 # Make Points
492495 for i in self .i_con :
493496 # >>> leah had some checks here that I didn't understand <<<
@@ -498,120 +501,6 @@ def createSubsystem(self, case=0, pristine=True, dd=None, ms=None):
498501 for i in self .i_sec :
499502 sec = self .getSubcomponent (i )
500503 sec .makeMoorPyLine (ms ) # this also will connect the Lines to Points
501-
502- """
503- n = len(self.subcomponents) # number of serial subcomponent items
504-
505- for i in range(n):
506-
507- if isinstance(items[i], list):
508- for subitem in items[i]: # go through each parallel subitem
509-
510- if isinstance(subitem, list): # if it's a concatenation of multiple things
511- assemble(subitem) # make sure that any sublist is assembled
512-
513- # attach the end objects of the subitem to the nodes before and after
514- if i > 0 and isinstance(items[i-1], Node): # attach to previous node
515- items[i-1].attach(subitem[0], end='a')
516- if i < n-1 and isinstance(items[i+1], Node): # attach to next node
517- items[i+1].attach(subitem[-1], end='b')
518- # note: this requires the end objects to be edges
519-
520- elif isinstance(subitem, Edge): # if the subitem is just one edge
521- print("THIS CASE SHOULDN'T HAPPEN - the list should be nested more")
522- breakpoint()
523- if i > 0 and isinstance(items[i-1], Node): # attach to previous node
524- items[i-1].attach(subitem, end='a')
525- if i < n-1 and isinstance(items[i+1], Node): # attach to next node
526- items[i+1].attach(subitem, end='b')
527- else:
528- raise Exception("Unsupported situation ... parallel subitems must be edges or concatenations")
529-
530- elif isinstance(items[i], Node) and isinstance(items[i+1], list):
531- pass # this node connects to a bridle or doubled section,
532- # so it will be hooked up in the next step
533-
534- elif isinstance(items[i], Node):
535- items[i].attach(items[i+1], end='a')
536-
537- elif isinstance(items[i], Edge) and isinstance(items[i+1], Node):
538- items[i+1].attach(items[i], end='b')
539-
540- else:
541- raise Exception('sequences is not alternating between nodes and edges')
542-
543-
544-
545- # some initialization steps.
546- self.nLines = len(lengths)
547- if len(connectors) == 0:
548- connectors = [{}]*(self.nLines - 1)
549- elif not len(connectors) == self.nLines - 1:
550- raise Exception('Length of connectors must be nLines - 1')
551-
552- if not len(types)==self.nLines:
553- raise Exception("The specified number of lengths and types is inconsistent.")
554-
555- # get cumulative sum of line lengths, starting from anchor segment
556- Lcsum = np.cumsum(np.array(lengths))
557-
558- # set end A location depending on whether configuration is suspended/symmetrical
559- if suspended==2: # symmetrical suspended case
560- rA = np.array([-0.5*self.span-self.rad_fair, 0, -1]) # shared line midpoint coordinates
561- self.shared = True # flag that it's being modeled as symmetric
562- elif suspended==1: # general suspended case
563- rA = np.array([-self.span-self.rad_fair, 0, self.z_fair]) # other suspended end
564- else: # normal anchored line case
565- rA = np.array([-self.span-self.rad_fair, 0, -self.depth]) # anchor coordinates
566- rB = np.array([-self.rad_fair, 0, self.z_fair]) # fairlead coordinates
567-
568- self.rA = rA
569- self.rB = rB
570-
571-
572- # Go through each line segment and add its upper point, add the line, and connect the line to the points
573- for i in range(self.nLines):
574-
575- # find the specified lineType dict and save a reference to it
576- if type(types[i]) == dict: # if it's a dictionary, just point to it
577- self.lineTypes[i] = types[i]
578- # otherwise we're assuming it's a string of the lineType name
579- elif types[i] in self.lineTypes: # first look for the name in the subsystem
580- self.lineTypes[i] = self.lineTypes[types[i]]
581- elif self.sys: # otherwise look in the parent system, if there is one
582- if types[i] in self.sys.lineTypes: # first look for the name in the subsystem
583- self.lineTypes[i] = self.sys.lineTypes[types[i]]
584- else:
585- raise Exception(f"Can't find lineType '{types[i]}' in the SubSystem or parent System.")
586- else:
587- raise Exception(f"Can't find lineType '{types[i]}' in the SubSystem.")
588-
589- # add the line segment using the reference to its lineType dict
590- if nSegs is None:
591- self.addLine(lengths[i], self.lineTypes[i])
592- elif isinstance(nSegs, (int, float)):
593- self.addLine(lengths[i], self.lineTypes[i], nSegs=nSegs)
594- elif isinstance(nSegs, list):
595- self.addLine(lengths[i], self.lineTypes[i], nSegs=nSegs[i])
596- else:
597- raise ValueError("Invalid type for nSegs. Expected None, a number, or a list.")
598-
599- # add the upper end point of the segment
600- if i==self.nLines-1: # if this is the upper-most line
601- self.addPoint(-1, rB, DOFs=[0,2]) # add the fairlead point (make it coupled)
602- #self.bodyList[0].attachPoint(i+2, rB) # attach the fairlead point to the body (two points already created)
603- else: # if this is an intermediate line
604- m = connectors[i].get('m', 0)
605- v = connectors[i].get('v', 0)
606- # add the point, initializing linearly between anchor and fairlead/midpoint
607- self.addPoint(0, rA + (rB-rA)*Lcsum[i]/Lcsum[-1], m=m, v=v, DOFs=[0,2])
608-
609- # attach the line to the points
610- self.pointList[-2].attachLine(i+1, 0) # attach end A of the line
611- self.pointList[-1].attachLine(i+1, 1) # attach end B of the line
612-
613- """
614-
615504
616505 else :
617506 ss = Subsystem (mooringSys = ms , depth = - dd ['zAnchor' ], rho = self .rho , g = self .g ,
0 commit comments