Skip to content

Commit 47cdce4

Browse files
committed
Tiny bug fix famodel_base, bug fix helpers, add tests
-- helpers bug fix: catch when a connector is not provided at the end of bridles - now we check for this and add empty connector object if needed -- tiny bug fix in famodel_base to prevent weird rounding - apparently, when assigning values into an array if you use array[:len(array)] = vals, it rounds the vals to whole numbers. Fixed this by adding >= to reassign value of whole array rather than just > -- add tests for parallel sections (bridles, double chains, etc) -- mooring.addMarineGrowth now works with updated dd (subcomponents instead of sections/connectors lists) - does not currently work for parallel sections -- arrayWatchCircle added warning that this does not currently work for parallel sections, WIP to add this capability -- tiny change to anchor.py to use mooring.sections method instead of sections in mooring design dictionary as this part of the design dictionary was removed -- updated ontologies for examples -- udpated tests
1 parent 9639f75 commit 47cdce4

17 files changed

+388
-162
lines changed

examples/OntologySample200m.yaml

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ mooring_systems:
144144

145145
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,4], 1 ]
147+
- [ semitaut-poly_1, 30 , drag-embedment1, 1, 1 ]
148148
- [ semitaut-poly_1, 150 , drag-embedment1, 2, 1 ]
149-
- [ semitaut-poly_1, 270, drag-embedment1, 3, [2,1] ]
149+
- [ semitaut-poly_1, 270, drag-embedment1, 3, 1 ]
150150

151151

152152
# Mooring line configurations
@@ -210,6 +210,29 @@ mooring_line_configs:
210210
d_nom: .182
211211
length: 199.8 # [m] length (unstretched)
212212

213+
semitaut-poly_1_bridle: # mooring line configuration identifier
214+
215+
name: Semitaut polyester configuration 1 # descriptive name
216+
217+
span: 642
218+
219+
sections: #in order from anchor to fairlead
220+
- mooringFamily: chain # ID of a mooring line section type
221+
d_nom: .1549
222+
length: 497.7 # [m] usntretched length of line section
223+
adjustable: True # flags that this section could be adjusted to accommodate different spacings...
224+
- connectorType: h_link
225+
- mooringFamily: polyester # ID of a mooring line section type
226+
d_nom: .182
227+
length: 119.8 # [m] length (unstretched)
228+
- subsections:
229+
- - mooringFamily: polyester # ID of a mooring line section type
230+
d_nom: .182
231+
length: 80 # [m] length (unstretched)
232+
- - mooringFamily: polyester # ID of a mooring line section type
233+
d_nom: .182
234+
length: 80 # [m] length (unstretched)
235+
213236

214237

215238
# Mooring line cross-sectional properties
@@ -1542,13 +1565,11 @@ platforms:
15421565
qtfPath : 'IEA-15-240-RWT-UMaineSemi.12d' # path to the qtf file for the platform
15431566
fairleads : # list of fairlead coordinates for the platform relative to platform coordinate and 0-degree heading
15441567
- name: fairlead1
1545-
r: 58
1546-
z: -14
1547-
headings: [30, 150, 270] # headings in degrees for the fairlead (if multiple headings, the fairlead will be repeated for each heading)
1568+
r_rel: [58, 0, -14]
1569+
headings: [30, 150, 270, 35] # headings in degrees for the fairlead (if multiple headings, the fairlead will be repeated for each heading)
15481570
Jtubes : # list of Jtube coordinates for the platform relative to platform coordinate and 0-degree heading
15491571
- name: Jtube1
1550-
r: 5
1551-
z: -20
1572+
r_rel: [5, 0, -20]
15521573
headings: [90, 210, 330] # headings in degrees for the Jtube (if multiple headings, the Jtube will be repeated for each heading)
15531574
type : FOWT
15541575
z_location : 0 # optional to put the depth of this platform type
@@ -1649,13 +1670,11 @@ platforms:
16491670
zFair : -15
16501671
fairleads : # list of fairlead coordinates for the platform relative to platform coordinate and 0-degree heading
16511672
- name: fairlead1
1652-
r: 58
1653-
z: -14
1654-
headings: [30, 150, 270] # headings in degrees for the fairlead (if multiple headings, the fairlead will be repeated for each heading)
1673+
r_rel: [58, 0, -14]
1674+
headings: [30, 150, 270, 35] # headings in degrees for the fairlead (if multiple headings, the fairlead will be repeated for each heading)
16551675
Jtubes:
16561676
- name: Jtube1
1657-
r: 5
1658-
z: -20
1677+
r_rel: [5, 0, -20]
16591678
headings: [90, 210, 330] # headings in degrees for the Jtube (if multiple headings, the Jtube will be repeated for each heading)
16601679
type : Substation
16611680

examples/OntologySample600m_shared.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,9 +1375,11 @@ mooring_line_configs:
13751375
length: 500 # [m] usntretched length of line section
13761376
- connectorType: triplate
13771377
- subsections: # double chain section
1378-
- - type: chain_155mm
1378+
- - mooringFamily: chain
1379+
d_nom: 0.1
13791380
length: 120
1380-
- - type: chain_155mm
1381+
- - mooringFamily: chain
1382+
d_nom: 0.1
13811383
length: 120
13821384
- connectorType: triplate
13831385
- type: rope # ID of a mooring line section type

examples/example_driver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@
3333
# create project object
3434
project = Project(file=dir+ontology_file,raft=False)
3535
# create moorpy system of the array, include cables in the system
36-
project.getMoorPyArray(cables=1)
36+
project.getMoorPyArray(cables=True)
3737
# plot in 3d, using moorpy system for the mooring and cable plots
3838
project.plot2d()
3939
project.plot3d()
4040

4141
#%% Section 2: Project with RAFT
4242
print('\nCreating project with RAFT \n')
4343
#create project object, automatically create RAFT object (and automatically create moorpy system in the process!)
44-
project = Project(file=ontology_file,raft=True)
44+
project = Project(file=dir+ontology_file,raft=True)
4545
# plot in 3d, use moorpy system for mooring and cables, use RAFT for platform, tower, and turbine visuals
4646
project.plot3d(fowt=True,draw_boundary=False,boundary_on_bath=False,save=True)
4747

examples/example_sharedmoorings.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515

1616

1717
# load in yaml
18-
project = Project(file=dir+filename,raft=False)
18+
project = Project(file=dir+filename, raft=True)
1919

2020

21-
project.getMoorPyArray()
22-
2321
# plot in 2d and 3d
2422
project.plot2d()
25-
#project.plot3d(fowt=True)
23+
project.plot3d(fowt=True)
2624

27-
#plt.show()
25+
plt.show()

examples/soil_sample.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--- MoorPy Soil Input File ---
2+
nGridX 3
3+
nGridY 3
4+
-1901 0 1900
5+
-1900 mud mud mud
6+
2 mud rock mud
7+
1900 mud mud mud
8+
--- SOIL TYPES ---
9+
Class Gamma Su0 k alpha phi UCS Em
10+
(name) (kN/m^3) (kPa) (kPa/m) (-) (deg) (MPa) (MPa)
11+
mud 4.7 2.39 1.41 0.7 - - -
12+
mud_firm 4.7 23.94 2.67 0.7 - - -
13+
rock - - - - - 7 50
14+
------------------
15+

famodel/anchors/anchor.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,9 @@ def makeMoorPyAnchor(self, ms):
123123
MoorPy system
124124
125125
'''
126-
# create anchor as a fixed point in MoorPy system
127-
ms.addPoint(1,self.r)
128-
# assign this point as mpAnchor in the anchor class instance
129-
self.mpAnchor = ms.pointList[-1]
126+
# create anchor as a fixed body in MoorPy system and assign to mpAnchor property
127+
r6 = [self.r[0],self.r[1],self.r[2],0,0,0]
128+
self.mpAnchor = ms.addBody(1,r6)
130129

131130
# add mass if available
132131
if 'm' in self.dd['design'] and self.dd['design']['m']:
@@ -550,14 +549,14 @@ def makeEqual_TaTm(mudloads):
550549
# get line type
551550
for att in self.attachments.values():
552551
if isinstance(att['obj'],Mooring):
553-
mtype = att['obj'].dd['sections'][0]['type']['material']
552+
mtype = att['obj'].sections()[0]['type']['material']
554553
if not 'chain' in mtype:
555554
print('No chain on seafloor, setting Ta=Tm')
556555
nolugload = True
557556
break
558557
else:
559-
md = att['obj'].dd['sections'][0]['type']['d_nom']
560-
mw = att['obj'].dd['sections'][0]['type']['w']
558+
md = att['obj'].sections()[0]['type']['d_nom']
559+
mw = att['obj'].sections()[0]['type']['w']
561560
soil = next(iter(self.soilProps.keys()), None)
562561
ground_conds = self.soilProps[soil]
563562
# update soil conds as needed to be homogeneous

famodel/famodel_base.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ def setPosition(self, r, theta=0, force=False):
455455
raise Exception("Can't setPosition of an object that's attached to a higher object unless force=True.")
456456

457457
# Store updated position and orientation
458-
if len(r) > len(self.r): # default r is 2D, but can be adjusted to 3D
458+
if len(r) >= len(self.r): # default r is 2D, but can be adjusted to 3D
459459
self.r = np.array(r)
460460
else: # if just a portion of r is being adjusted, only change up to length of initial r
461461
self.r[:len(r)] = r
@@ -491,7 +491,6 @@ def setPosition(self, r, theta=0, force=False):
491491

492492
# Compute the attachment's position
493493
r_att = self.r + np.matmul(self.R, att['r_rel'])
494-
495494
# set position of any attached node that isn't subordinate to another node
496495
# (prevents infinite loop of setPositioning for nodes)
497496
if isinstance(att['obj'], Node):

famodel/helpers.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,8 @@ def getMoorings(lcID, lineConfigs, connectorTypes, pfID, proj):
703703

704704
lineLast = 1 # boolean whether item with index k-1 is a line. Set to 1 for first run through of for loop
705705
ct = 0 # counter for number of line types
706-
for k in range(0,len(lineConfigs[lcID]['sections'])): # loop through each section in the line
706+
nsec = len(lineConfigs[lcID]['sections']) # number of sections
707+
for k in range(0,nsec): # loop through each section in the line
707708

708709
lc = lineConfigs[lcID]['sections'][k] # set location for code clarity later
709710
# determine if it's a line type or a connector listed
@@ -762,7 +763,7 @@ def getMoorings(lcID, lineConfigs, connectorTypes, pfID, proj):
762763
sublineLast = [lineLast]*len(lc['subsections']) # to check if there was a connector provided before this
763764
for ii,sub in enumerate(lc['subsections']):
764765
config[-1].append([])
765-
for subsub in sub:
766+
for jj,subsub in enumerate(sub):
766767
if 'connectorType' in subsub and sublineLast[ii]:
767768
cID = subsub['connectorType']
768769
if cID in connectorTypes:
@@ -791,6 +792,13 @@ def getMoorings(lcID, lineConfigs, connectorTypes, pfID, proj):
791792
sublineLast[ii] = 1
792793
else:
793794
raise Exception(f"keys in subsection line definitions must either be 'type', 'mooringFamily', or 'connectorType'")
795+
# if this is the last section and the last part of the subsection in the section, it needs to end on a connector
796+
# so, add a connector if last part of subsection was a line!
797+
if sublineLast[ii] and k==nsec-1 and jj==len(sub)-1:
798+
# end bridle needs connectors added
799+
config[-1][-1].append({})
800+
sublineLast[ii] = 0
801+
794802
lineLast = sublineLast[-1] # TODO: LHS: think how to handle this situation for error checking...
795803
else:
796804
# not a connector or a line
@@ -963,9 +971,17 @@ def calc_midpoint(point):
963971
if isinstance(point[0],list) or isinstance(point[0],np.ndarray):
964972
pointx = sum([x[0] for x in point])/len(point)
965973
pointy = sum([x[1] for x in point])/len(point)
974+
# add z component if needed
975+
if len(point[0])==3:
976+
pointz = sum([x[2] for x in point])/len(point)
977+
return([pointx,pointy,pointz])
966978
else:
967979
pointx = point[0]
968980
pointy = point[1]
981+
# add z component if needed
982+
if len(point)==3:
983+
pointz = point[2]
984+
return([pointx,pointy,pointz])
969985

970986
return([pointx,pointy])
971987

famodel/mooring/connector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,5 +174,5 @@ def makeMoorPyLine(self, ms):
174174
pointB = self.attached_to[1].mpConn.number
175175

176176
# Create a Line for the section in MoorPy system
177-
ms.addLine(self['L'], self['type'], pointA=pointA, pointB=pointB)
177+
self.mpLine = ms.addLine(self['L'], self['type'], pointA=pointA, pointB=pointB)
178178

0 commit comments

Comments
 (0)