Skip to content

Commit ea00174

Browse files
committed
In progress commit
-- started changing loadDesign helper functiosn to work with parallel mooring structures within a mooring line i.e. bridles etc -- read in subsections poirtions of mooring line configs and separate out to proper connectors and sections list of dd -- upload example of use of bridles/double chain section in ontologySample200m.yaml -- some hair-brained ideas in here that probably should be removed such as: - passing in a subcons list to mooring object on initialization. Original idea was to create the connectors and sections list, and a list of the subcons in the proper order at the same time on load in, since that information is easily available, to help with building out the subcomponent list and avoid extra logic requried to re-form that ordre from the connectors and sections list. - the issue with this is now when we make the contents of connector and sections list of dd into actual Connector and Section objects, we have no way to map to the subcons list so purpose is likely defeated here.. -- fixed a few random bugs in other parts of the code unrelated
1 parent 597a4b6 commit ea00174

File tree

5 files changed

+139
-46
lines changed

5 files changed

+139
-46
lines changed

examples/Inputs/OntologySample200m.yaml

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ mooring_systems:
142142
ms3:
143143
name: 3-line semi-taut polyester mooring system
144144

145-
keys: [MooringConfigID, heading, anchorType, fairlead] # fairlead listing is optional; if not specified, fairlead list follows order of fairleads in the platform definition
145+
keys: [MooringConfigID, heading, anchorType, fairlead, lug] # fairlead and lug listings are optional; if not specified, fairlead list follows order of fairleads in the platform definition
146146
data:
147-
- [ semitaut-poly_1, 30 , drag-embedment1, 1 ]
148-
- [ semitaut-poly_1, 150 , drag-embedment1, 2 ]
149-
- [ semitaut-poly_1, 270, drag-embedment1, 3 ]
147+
- [ semitaut-poly_1, 30 , drag-embedment1, [1,4], 1 ]
148+
- [ semitaut-poly_1, 150 , drag-embedment1, 2, 1 ]
149+
- [ semitaut-poly_1, 270, drag-embedment1, 3, [2,1] ]
150150

151151

152152
# Mooring line configurations
@@ -159,23 +159,39 @@ mooring_line_configs:
159159

160160

161161
sections:
162+
- subsections: # subsections are used to define segments of mooring that run in parallel, such as a bridle
163+
- - connectorType: h_link # end A connector to the fairlead A0
164+
- type: chain_185 # each outer list is a separate subsection, each inner list is the segments of the subsection that are connected in series
165+
length: 40
166+
- - connectorType: h_link # end A connector to the fairlead A1
167+
- type: chain_185
168+
length: 40
162169
- connectorType: h_link
163170
- type: rope
164-
length: 150
171+
length: 110
165172
- connectorType: clump_weight_80
166173
- type: rope
167-
length: 1172
174+
length: 500
175+
- connectorType: triplate
176+
- subsections: # a subsection that is not on the end of a mooring connects back to the connector on either side
177+
- - type: chain_185
178+
length: 180
179+
- - type: chain_185
180+
length: 180
181+
- connectorType: triplate
182+
- type: rope
183+
length: 500
168184
- connectorType: clump_weight_80
169185
- type: rope
170-
length: 150
186+
length: 110
171187
- connectorType: h_link
172-
173-
bridle_sections:
174-
bridle_radius:
175-
- type:
176-
- connectorType:
177-
- type:
178-
length:
188+
- subsections:
189+
- - type: chain_185
190+
length: 40
191+
- connectorType: h_link # end B connector to the fairlead B0
192+
- - type: chain_185
193+
length: 40
194+
- connectorType: h_link # end B connector to the fairlead B1
179195

180196

181197
semitaut-poly_1: # mooring line configuration identifier

famodel/cables/static_cable.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,12 @@ def updateRouting(self,coords=None):
181181
182182
'''
183183

184-
if coords:
184+
if coords is not None and len(coords)>0:
185185
self.x = [coord[0] for coord in coords] # cable route vertex global x coordinate [m]
186186
self.y = [coord[1] for coord in coords] # cable route vertex global y coordinate [m]
187187
# Check if radius available
188188
if len(coords[0]) == 3:
189189
self.r = [coord[2] for coord in coords] # cable route vertex corner radius [m]
190-
191190

192191
# update static cable length
193192
self.getLength()

famodel/helpers.py

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,7 @@ def getMoorings(lcID, lineConfigs, connectorTypes, pfID, proj):
701701
m_config = {'sections':[],'anchor':{},'span':{},'zAnchor':{}}#,'EndPositions':{}}
702702
# set up connector dictionary
703703
c_config = []
704+
config = []
704705

705706
lineLast = 1 # boolean whether item with index k-1 is a line. Set to 1 for first run through of for loop
706707
ct = 0 # counter for number of line types
@@ -712,6 +713,7 @@ def getMoorings(lcID, lineConfigs, connectorTypes, pfID, proj):
712713
# this is a line
713714
if lineLast: # previous item in list was a line (or this is the first item in a list)
714715
# no connector was specified for before this line - add an empty connector
716+
config.append({})
715717
c_config.append({})
716718
# set line information
717719
lt = MooringProps(lc, proj.lineTypes, proj.rho_water, proj.g)
@@ -723,6 +725,7 @@ def getMoorings(lcID, lineConfigs, connectorTypes, pfID, proj):
723725
m_config['sections'][ct]['type']['EA'] = float(lt['EA'])
724726
# set line length
725727
m_config['sections'][ct]['L'] = lc['length']
728+
config.append(m_config['sections'][ct])
726729
# update counter for line types
727730
ct = ct + 1
728731
# update line last boolean
@@ -740,22 +743,59 @@ def getMoorings(lcID, lineConfigs, connectorTypes, pfID, proj):
740743
if cID in connectorTypes:
741744
c_config.append(connectorTypes[cID]) # add connector to list
742745
c_config[-1]['type'] = cID
746+
config.append(c_config[-1])
743747
else:
744748
# try pointProps
745749
try:
746750
props = loadPointProps(None)
747751
design = {f"num_c_{cID}":1}
748752
c_config.append(getPointProps(design, Props=props))
753+
config.append(c_config[-1])
749754
except Exception as e:
750755
raise Exception(f"Connector type {cID} not found in connector_types dictionary, and getPointProps raised the following exception:",e)
751756

752757
# update lineLast boolean
753758
lineLast = 0
759+
elif 'subsections' in lc:
760+
# TODO: LHS: ERROR CHECKING FOR ORDER OF COMPONENTS PROVIDED WITHIN SUBSECTIONS, ADD IN NEEDED CONNECTORS!!
761+
c_config.append([])
762+
m_config.append([])
763+
sublineLast = [lineLast]*len(lc['subsections']) # to check if there was a connector provided before this
764+
for ii,sub in enumerate(lc['subsections']):
765+
c_config[-1].append([])
766+
m_config[-1].append([])
767+
config.append([])
768+
for subsub in sub:
769+
if 'connectorType' in subsub:
770+
if cID in connectorTypes:
771+
cID = subsub['connectorType']
772+
c_config[-1][-1].append(connectorTypes[cID])
773+
config[-1][-1].append(connectorTypes[cID])
774+
else:
775+
# try pointProps
776+
try:
777+
props = loadPointProps(None)
778+
design = {f"num_c_{cID}":1}
779+
c_config[-1][-1].append(getPointProps(design, Props=props))
780+
config[-1][-1].append(c_config[-1][-1])
781+
except Exception as e:
782+
raise Exception(f"Connector type {cID} not found in connector_types dictionary, and getPointProps raised the following exception:",e)
783+
sublineLast[ii] = 0
784+
elif 'type' or 'mooringFamily' in subsub:
785+
lt = MooringProps(subsub)
786+
m_config[-1][-1].append({'type':lt,
787+
'L': subsub['length']})
788+
config[-1][-1].append(m_config[-1][-1])
789+
sublineLast[ii] = 1
790+
else:
791+
raise Exception(f"keys in subsection line definitions must either be 'type', 'mooringFamily', or 'connectorType'")
792+
lineLast = sublineLast[-1] # TODO: LHS: think how to handle this situation for error checking...
754793
else:
755794
# not a connector or a line
756-
raise Exception(f"Please make sure that all section entries for line configuration '{lcID}' are either line sections (which must have a 'type' key) or connectors (which must have a 'connectorType' key")
795+
raise Exception(f"Please make sure that all section entries for line configuration '{lcID}' are either line sections (which must have a 'type' key), connectors (which must have a 'connectorType' key, or subsections")
757796

758797
# check if line is a shared symmetrical configuration
798+
# TODO: LHS figure out subsections with symmetrical lines... or just ban symmetrical for situations with subsections...
759799
if 'symmetric' in lineConfigs[lcID] and lineConfigs[lcID]['symmetric']:
760800
if not lineLast: # check if last item in line config list was a connector
761801
for ii in range(0,ct):
@@ -787,7 +827,8 @@ def getMoorings(lcID, lineConfigs, connectorTypes, pfID, proj):
787827

788828
m_config['connectors'] = c_config # add connectors section to the mooring dict
789829

790-
return(m_config) #, c_config)
830+
return(m_config, config) #, c_config)
831+
791832

792833

793834
def getConnectors(c_config, mName, proj):
@@ -871,15 +912,16 @@ def angle(pt):
871912
for anch in anchor_buffs:
872913
if cab.intersects(anch):
873914
# Get the start and end of the detour (the two closest points to the buffer)
874-
segments = []
915+
new_points = []
875916
# make additional points on the line on either side of anchor
876917
dist_to_anch = cab.line_locate_point(anch.centroid)
877918
if dist_to_anch > 100:
878-
segments.append(cab.interpolate(dist_to_anch - 100))
919+
new_points.append(cab.interpolate(dist_to_anch - 100))
879920
if cab.length - dist_to_anch > 100:
880-
segments.append(cab.interpolate(dist_to_anch + 100))
921+
new_points.append(cab.interpolate(dist_to_anch + 100))
881922

882-
start = np.array(segments[0].coords[-1])
923+
# pull out the coordinates of the first new point
924+
start = np.array(new_points[0].coords[-1])
883925

884926
# Get buffer center and radius
885927
center = np.array(anch.centroid.coords[0])
@@ -891,8 +933,21 @@ def angle(pt):
891933
# Generate point along the arc (detour)
892934
arc_point = [center[0] + radius * np.cos(angle_start+np.pi/2), center[1] + radius * np.sin(angle_start+np.pi/2)]
893935

936+
# determine relative positions of new routing points among other routing points
937+
rel_dist = []
938+
orig_coords = []
939+
breakpoint()
940+
for i,x in enumerate(proj.cableList[name].subcomponents[2].x):
941+
y = proj.cableList[name].subcomponents[2].y[i]
942+
rel_dist.append(cab.line_locate_point(sh.Point([x,y])))
943+
orig_coords.append([x,y])
944+
all_dists = np.hstack((rel_dist,dist_to_anch-100, dist_to_anch+100, dist_to_anch))
945+
all_points = np.vstack((orig_coords,[coord.coords[0] for coord in new_points],arc_point))
946+
sorted_idxs = np.argsort(all_dists)
947+
final_points = all_points[sorted_idxs]
948+
894949
# add new routing point in cable object
895-
proj.cableList[name].subcomponents[2].updateRouting([list(segments[0].coords[1:]) + arc_point + list(segments[1].coords[:-1])])
950+
proj.cableList[name].subcomponents[2].updateRouting(final_points)
896951

897952

898953

famodel/mooring/mooring.py

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Mooring(Edge):
1616
'''
1717

1818
def __init__(self, dd=None, subsystem=None, anchor=None,
19-
rho=1025, g=9.81,id=None,shared=0):
19+
rho=1025, g=9.81,id=None,shared=0,subcons=None):
2020
'''
2121
Parameters
2222
----------
@@ -91,18 +91,38 @@ def __init__(self, dd=None, subsystem=None, anchor=None,
9191
self.i_con = []
9292
self.i_sec = []
9393
# Turn what's in dd and turn it into Sections and Connectors
94+
con_i = 0
9495
for i, con in enumerate(self.dd['connectors']):
95-
if con and 'type' in con:
96-
Cid = con['type']+str(i)
97-
else:
98-
Cid = None
99-
self.addConnector(con, i, id=Cid, insert=False)
100-
96+
if isinstance(self.dd['connectors'][i],list):
97+
for j,subcon in enumerate(self.dd['connectors'][i]):
98+
if isinstance(self.dd['connectors'][i][j],list):
99+
if con and 'type' in con:
100+
Cid = con['type']+str(con_i)
101+
else:
102+
Cid = None
103+
self.addConnector(con, con_i, id=Cid, insert=False)
104+
con_i += 1
105+
else:
106+
if con and 'type' in con:
107+
Cid = con['type']+str(con_i)
108+
else:
109+
Cid = None
110+
self.addConnector(con, con_i, id=Cid, insert=False)
111+
con_i += 1
112+
sub_i = 0
101113
for i, sec in enumerate(self.dd['sections']):
102-
self.addSection(sec['L'],sec['type'],i, insert=False)
114+
if isinstance(self.dd['sections'][i],list):
115+
for j,subcon in enumerate(self.dd['sections'][i]):
116+
if isinstance(self.dd['sections'][i][j],list):
117+
self.addSection(sec['L'],sec['type'],sub_i, insert=False)
118+
sub_i += 1
119+
else:
120+
self.addSection(sec['L'],sec['type'],sub_i, insert=False)
121+
sub_i += 1
122+
103123

104124
# connect subcomponents and update i_sec and i_conn lists
105-
self.connectSubcomponents()
125+
self.connectSubcomponents(subcons)
106126

107127

108128

@@ -1030,7 +1050,7 @@ def addConnector(self, conn_dd, index, id=None, insert=True):
10301050

10311051
return(newconn)
10321052

1033-
def connectSubcomponents(self):
1053+
def connectSubcomponents(self, subcons=None):
10341054

10351055
# first disconnect any current subcomponents
10361056
for ii in self.i_sec:
@@ -1047,11 +1067,12 @@ def connectSubcomponents(self):
10471067
# self.subcomponents[-1].detach(att)
10481068

10491069
# Now connect the new set of subcomponents and store them in self(Edge).subcomponents!
1050-
subcons = [] # temporary list of node-edge-node... to pass to the function
1051-
for i in range(self.n_sec):
1052-
subcons.append(self.dd['connectors'][i])
1053-
subcons.append(self.dd['sections'][i])
1054-
subcons.append(self.dd['connectors'][-1])
1070+
if subcons is None:
1071+
subcons = [] # temporary list of node-edge-node... to pass to the function
1072+
for i in range(self.n_sec):
1073+
subcons.append(self.dd['connectors'][i])
1074+
subcons.append(self.dd['sections'][i])
1075+
subcons.append(self.dd['connectors'][-1])
10551076
self.addSubcomponents(subcons) # Edge method to connect and store em
10561077

10571078
# Indices of connectors and sections in self.subcomponents list

famodel/project.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -517,12 +517,13 @@ def loadDesign(self, d, raft=True):
517517
lineconfig = mySys[j]['MooringConfigID']
518518

519519
# create mooring and connector dictionary
520-
m_config = getMoorings(lineconfig, lineConfigs, connectorTypes, arrayInfo[i]['ID'], self)
520+
m_config, config = getMoorings(lineconfig, lineConfigs, connectorTypes, arrayInfo[i]['ID'], self)
521521

522522
# create mooring object, attach ends, reposition
523523
moor = self.addMooring(id=name,
524524
heading=headings[j]+platform.phi,
525-
dd=m_config, reposition=False)
525+
dd=m_config, subcons=config,
526+
reposition=False)
526527

527528
anch = self.addAnchor(id=name, dd=ad, mass=mass)
528529

@@ -585,11 +586,12 @@ def loadDesign(self, d, raft=True):
585586
lineconfig = arrayMooring[j]['MooringConfigID']
586587

587588
# create mooring and connector dictionary for that line
588-
m_config = getMoorings(lineconfig, lineConfigs, connectorTypes, PF[0].id, self)
589+
m_config, config = getMoorings(lineconfig, lineConfigs, connectorTypes, PF[0].id, self)
589590

590591
# create mooring class instance
591592
moor = self.addMooring(id=str(PF[1].id)+'-'+str(PF[0].id),
592-
dd=m_config, shared=1)
593+
dd=m_config, subcons=config,
594+
shared=1)
593595

594596
# attach ends
595597
flIDB = PF[0].id+'_F'+str(arrayMooring[j]['fairleadB'])
@@ -612,13 +614,13 @@ def loadDesign(self, d, raft=True):
612614
# get configuration for that line
613615
lineconfig = arrayMooring[j]['MooringConfigID']
614616
# create mooring and connector dictionary for that line
615-
m_config = getMoorings(lineconfig, lineConfigs, connectorTypes, PF[0].id, self)
617+
m_config, config = getMoorings(lineconfig, lineConfigs, connectorTypes, PF[0].id, self)
616618
# get letter number for mooring line
617619
ind = len(PF[0].getMoorings())
618620

619621
# create mooring class instance, attach to end A and end B objects, reposition
620622
moor = self.addMooring(id=str(PF[0].id)+alph[ind],
621-
dd=m_config)
623+
dd=m_config, subcons=config)
622624

623625
# check if anchor instance already exists
624626
if any(tt == arrayMooring[j]['endA'] for tt in self.anchorList): # anchor name exists already in list
@@ -1614,7 +1616,7 @@ def addFairlead(self, id=None, platform=None, r_rel=[0,0,0],
16141616
def addMooring(self, id=None, endA=None, endB=None, heading=0, dd={},
16151617
section_types=[], section_lengths=[],
16161618
connectors=[], span=0, shared=0, reposition=False, subsystem=None,
1617-
**adjuster_settings):
1619+
subcons=None, **adjuster_settings):
16181620
# adjuster=None,
16191621
# method = 'horizontal', target = None, i_line = 0,
16201622
'''
@@ -1693,7 +1695,7 @@ def addMooring(self, id=None, endA=None, endB=None, heading=0, dd={},
16931695
'rad_fair':self.platformList[id_part[0]].rFair if id_part else 0,
16941696
'z_fair':self.platformList[id_part[0]].zFair if id_part else 0}
16951697

1696-
mooring = Mooring(dd=dd, id=id, subsystem=subsystem) # create mooring object
1698+
mooring = Mooring(dd=dd, id=id, subsystem=subsystem, subcons=subcons) # create mooring object
16971699

16981700
# update shared prop if needed
16991701
if len(id_part)==2 and shared<1:

0 commit comments

Comments
 (0)