Skip to content

Commit 83e4686

Browse files
committed
WIP creating MoorPy objects for Moorings with bridle/parallel parts
- Copied some of example_sharedmoorings.py into project.py for quick testing. - Moved the Subsystem addition to a MoorPy System's lineList into the Mooring.createSubystem method to consolidate. - Section class: added mpLine attribute and makeMoorPyLine method. - Mooring class - - createSubsystem: adapted to also create the MoorPy objects for bridle/parallel situations, with no subsystem. Method can be renamed at some point. - - Mooring.parallels flags whether there are parallel subcomponents in which case there is no subsystem. - Project.createMoorPyArray: worked on adapting this to work with bridle/parallel cases. Also streamlined a few for loops to not index things as often. This part is very much in progress!
1 parent 3b0e1f0 commit 83e4686

File tree

5 files changed

+392
-106
lines changed

5 files changed

+392
-106
lines changed

examples/example_sharedmoorings.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,21 @@
44
a shared anchor. The purpose of this example is to show the Ontology inputs for
55
shared systems and how these systems might appear in FAModel
66
"""
7-
import os
87
import famodel
98
from famodel import Project
109
import matplotlib.pyplot as plt
1110

1211
# point to location of yaml file with uniform array info
13-
input_directory = 'Inputs/' # relative location of directory for input files (yaml, bath files, etc)
14-
filename = 'OntologySample600m_shared.yaml' # yaml file for project
15-
16-
17-
# switch to directory of input files
18-
os.chdir(input_directory)
12+
filename = 'Inputs/OntologySample600m_shared.yaml' # yaml file for project
1913

2014
# load in yaml
2115
project = Project(file=filename,raft=False)
2216

17+
18+
project.getMoorPyArray()
19+
2320
# plot in 2d and 3d
24-
project.plot2d()
21+
#project.plot2d()
2522
#project.plot3d(fowt=True)
2623

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

famodel/mooring/connector.py

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ def __init__(self,id, r=[0,0,0], **kwargs):
4545
self.cost = {}
4646

4747
self.getProps()
48-
48+
49+
4950
def makeMoorPyConnector(self, ms):
5051
'''Create a MoorPy connector object in a MoorPy system
5152
Parameters
@@ -57,7 +58,6 @@ def makeMoorPyConnector(self, ms):
5758
-------
5859
ms : class instance
5960
MoorPy system
60-
6161
'''
6262
# create connector as a point in MoorPy system
6363
ms.addPoint(0,self.r)
@@ -71,11 +71,10 @@ def makeMoorPyConnector(self, ms):
7171

7272
# set point type in ms
7373
self.getProps()
74-
7574

76-
7775
return(ms)
7876

77+
7978
def getProps(self):
8079
'''
8180
Wrapper function to get moorpy point props dictionary
@@ -104,6 +103,7 @@ def getProps(self):
104103

105104
return(pt)
106105

106+
107107
def getCost(self,update=True, fx=0.0, fz=0.0, peak_tension=None, MBL=None):
108108
'''Get cost of the connector from MoorPy pointProps.
109109
Wrapper for moorpy's getCost_and_MBL helper function'''
@@ -139,4 +139,34 @@ def __init__(self,id, **kwargs):
139139

140140
# if the type dict wasn't provided, set as none to start with
141141
if not 'type' in self:
142-
self['type'] = None
142+
self['type'] = None
143+
144+
# MoorPy Line object for the section
145+
self.mpLine = None
146+
147+
148+
def makeMoorPyLine(self, ms):
149+
'''Create a MoorPy Line object in a MoorPy system.
150+
If this section is attached to connectors that already have associated
151+
MoorPy point objects, then those attachments will also be made in
152+
MoorPy.
153+
154+
Parameters
155+
----------
156+
ms : MoorPy System object
157+
The MoorPy system to create the Line object in.
158+
'''
159+
160+
# See if this section is attached to any already-created MoorPy Points
161+
pointA = 0
162+
if self.attached_to[0]: # if an end A attachment
163+
if self.attached_to[0].mpConn: # if it has a MoorPy point object
164+
pointA = self.attached_to[0].mpConn.number # get its number
165+
pointB = 0
166+
if self.attached_to[1]:
167+
if self.attached_to[1].mpConn:
168+
pointB = self.attached_to[1].mpConn.number
169+
170+
# Create a Line for the section in MoorPy system
171+
ms.addLine(self['L'], self['type'], pointA=pointA, pointB=pointB)
172+

0 commit comments

Comments
 (0)