Skip to content

Commit

Permalink
Improvements for Line z_extreme and Subsystem lineTypes
Browse files Browse the repository at this point in the history
- Line.z_extreme provides absolute z elevation of highest/lowest
  point on a line section (in direction of its wet weight).
- Subsystem.makeGeneric now can handle a list of lineType dicts
  in which case it won't make new lineType entries.
- Added a helper function for drawing a 3D box - nice for
  visualizing fairlead positions on a body.
  • Loading branch information
mattEhall committed Mar 7, 2024
1 parent 696c9ef commit 4ae4b23
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
3 changes: 2 additions & 1 deletion moorpy/Catenary.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def catenary(XF, ZF, L, EA, W, CB=0, alpha=0, HF0=0, VF0=0, Tol=0.000001, nNodes
stiffnessBA - 2D stiffness matrix for force at B due to movement of A [N/m].
LBot - length of line section laying on the seabed [m].
ProfileType
Zextreme - extreme z coordinate of the line section (in direction of wet weight) [m].
Zextreme - extreme z coordinate of the line section (in direction of
wet weight), relative to height of end A [m].
'''

Expand Down
18 changes: 18 additions & 0 deletions moorpy/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,24 @@ def addToDict(dict1, dict2, key1, key2, default=None):
dict2[key2] = val


def drawBox(ax, r1, r2, color=[0,0,0,0.2]):
'''Draw a box along the x-y-z axes between two provided corner points.'''


ax.plot([r1[0], r2[0]], [r1[1], r1[1]], [r1[2], r1[2]], color=color) # along x
ax.plot([r1[0], r2[0]], [r2[1], r2[1]], [r1[2], r1[2]], color=color)
ax.plot([r1[0], r2[0]], [r1[1], r1[1]], [r2[2], r2[2]], color=color)
ax.plot([r1[0], r2[0]], [r2[1], r2[1]], [r2[2], r2[2]], color=color)
ax.plot([r1[0], r1[0]], [r1[1], r2[1]], [r1[2], r1[2]], color=color) # along y
ax.plot([r2[0], r2[0]], [r1[1], r2[1]], [r1[2], r1[2]], color=color)
ax.plot([r1[0], r1[0]], [r1[1], r2[1]], [r2[2], r2[2]], color=color)
ax.plot([r2[0], r2[0]], [r1[1], r2[1]], [r2[2], r2[2]], color=color)
ax.plot([r1[0], r1[0]], [r1[1], r1[1]], [r1[2], r2[2]], color=color) # along z
ax.plot([r1[0], r1[0]], [r2[1], r2[1]], [r1[2], r2[2]], color=color)
ax.plot([r2[0], r2[0]], [r1[1], r1[1]], [r1[2], r2[2]], color=color)
ax.plot([r2[0], r2[0]], [r2[1], r2[1]], [r1[2], r2[2]], color=color)


def makeTower(twrH, twrRad):
'''Sets up mesh points for visualizing a cylindrical structure (should align with RAFT eventually.'''

Expand Down
1 change: 1 addition & 0 deletions moorpy/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,7 @@ def staticSolve(self, reset=False, tol=0.0001, profiles=0):

# save other important info
self.LBot = info["LBot"]
self.z_extreme = self.rA[2] + info["Zextreme"]
self.info = info

# save forces in global reference frame
Expand Down
13 changes: 9 additions & 4 deletions moorpy/subsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,11 @@ def makeGeneric(self, lengths, types, suspended=0):
lengths : list of floats
List of each section's length. This also implies the number of
sections.
types : list of dicts
List of lineType names for each section. These names must match
keys in the parent system lineTypes dictionary or the subsystem's lineTypes dictionary...
types : list of strings or dicts
List of lineType names or dicts for each section. If strings,
these names must match keys in the parent system lineTypes
dictionary or the subsystem's lineTypes dictionary. If dicts,
these dicts are referred to for each lineType (by reference).
suspended : int
Selector shared/suspended cases:
- 0 (default): end A is on the seabed,
Expand Down Expand Up @@ -169,7 +171,10 @@ def makeGeneric(self, lengths, types, suspended=0):
for i in range(self.nLines):

# find the specified lineType dict and save a reference to it
if types[i] in self.lineTypes: # first look for the name in the subsystem
if type(types[i]) == dict: # if it's a dictionary, just point to it
self.lineTypes[i] = types[i]
# otherwise we're assuming it's a string of the lineType name
elif types[i] in self.lineTypes: # first look for the name in the subsystem
self.lineTypes[i] = self.lineTypes[types[i]]
elif self.sys: # otherwise look in the parent system, if there is one
if types[i] in self.sys.lineTypes: # first look for the name in the subsystem
Expand Down
2 changes: 1 addition & 1 deletion moorpy/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -2599,7 +2599,7 @@ def getCoupledStiffnessA(self, lines_only=False, tensions=False):
# invert matrix
K_inv_all = np.linalg.inv(K_all)

# remove free DOFs (this corresponds to saying that the same of forces on these DOFs will remain zero)
# remove free DOFs (this corresponds to saying that the sum of forces on these DOFs will remain zero)
#indices = list(range(n)) # list of DOF indices that will remain active for this step
mask = [True]*n # this is a mask to be applied to the array K indices

Expand Down

0 comments on commit 4ae4b23

Please sign in to comment.