Skip to content

Commit

Permalink
new System.disconnectLineEnd method does like it says
Browse files Browse the repository at this point in the history
  • Loading branch information
mattEhall committed Jun 24, 2024
1 parent 8180b84 commit adf5573
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 18 deletions.
3 changes: 2 additions & 1 deletion moorpy/Catenary.py
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,8 @@ def step_func_cat(X, args, Y, info, Ytarget, err, tols, iter, maxIter):


# Tricky case for sloped seabed (prone to overestimating LBot unless trapped corrected in the solve)
(fAH1, fAV1, fBH1, fBV1, info1) = catenary(121.5, 17.5, 138.5, 1232572089, 2456.8, CB=0.0, alpha=-2.6, HF0=428113, VF0=396408, Tol=0.0005, nNodes=41, plots=1)
#(fAH1, fAV1, fBH1, fBV1, info1) = catenary(121.5, 17.5, 138.5, 1232572089, 2456.8, CB=0.0, alpha=-2.6, HF0=428113, VF0=396408, Tol=0.0005, nNodes=41, plots=1)
(fAH1, fAV1, fBH1, fBV1, info1) = catenary(121.09772794232714, -1.8384100597014594, 101.50770310432262, 1232572089.6, 2456.820077481978, CB=0.0, alpha=-0.8659609923714943, HF0=20534.12538249187, VF0=53055.020668169294, Tol=0.0005, nNodes=41, plots=1)

"""
Tol =2e-05
Expand Down
22 changes: 17 additions & 5 deletions moorpy/body.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,6 @@ def attachPoint(self, pointID, rAttach):
The identifier ID number of a point
rAttach : array
The position of the point relative to the body's frame [m]
Returns
-------
None.
'''

self.attachedP.append(pointID)
Expand All @@ -118,6 +113,23 @@ def attachPoint(self, pointID, rAttach):
if self.sys.display > 1:
print("attached Point "+str(pointID)+" to Body "+str(self.number))

"""
def dettachPoint(self, pointID):
'''Removes a Point from the Body.
Parameters
----------
pointID : int
The identifier ID number of a point
rAttach : array
The position of the point relative to the body's frame [m]
'''
find pointID index in self.attachedP
delete entry from self.attachedP and rPointRel
set point type to free
"""

def attachRod(self, rodID, endCoords):
'''Adds a Point to the Body, at the specified relative position on the body.
Expand Down
20 changes: 8 additions & 12 deletions moorpy/point.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ def attachLine(self, lineID, endB):
The identifier ID number of a line
endB : boolean
Determines which end of the line is attached to the point
Returns
-------
None.
'''

self.attached.append(lineID)
Expand All @@ -108,15 +103,16 @@ def detachLine(self, lineID, endB):
The identifier ID number of a line
endB : boolean
Determines which end of the line is to be detached from the point
Returns
-------
None.
'''

self.attached.pop(self.attached.index(lineID))
self.attachedEndB.pop(self.attachedEndB.index(endB))
# get attachment index
i1 = self.attached.index(lineID)
i2 = self.attachedEndB.index(endB)
if not i1==i2:
raise Exception("issue with the right end of the line to detach...")

self.attached.pop(i1)
self.attachedEndB.pop(i1)
print("detached Line "+str(lineID)+" from Point "+str(self.number))


Expand Down
29 changes: 29 additions & 0 deletions moorpy/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,36 @@ def removeLine(self, lineID):
raise Exception("Invalid line number")
"""

def disconnectLineEnd(self, lineID, endB):
'''Disconnects the specified end of a Line object from whatever point
it's attached to, and instead attaches it to a new free point.
'''

# for now assume the line is at the expected index
line = self.lineList[lineID-1]

if not line.number == lineID:
raise Exception(f"Error lineID {lineID} isn't at the corresponding lineList index.")

# detach line from whatever point it's attached to
for point in self.pointList:
if lineID in point.attached:
if point.attachedEndB[point.attached.index(lineID)] == endB:
point.detachLine(lineID, endB)
break

# create new free point to attach the line end to
if endB:
r = line.rB
else:
r = line.rA

self.addPoint(0, r)

self.pointList[-1].attachLine(lineID, endB)


def addLineType(self, type_string, d, mass, EA, name=""):
'''Convenience function to add a LineType to a mooring system or adjust
the values of an existing line type if it has the same name/key.
Expand Down

0 comments on commit adf5573

Please sign in to comment.