Skip to content

Commit

Permalink
lines2subsystem bug fix
Browse files Browse the repository at this point in the history
-- fixed bug found by lcarmo in lines2subsystem
  • Loading branch information
lsirkis committed Dec 17, 2024
1 parent 4444715 commit 4104d6e
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions moorpy/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,8 @@ def lines2ss(ms):

lines = list(subsys_lines)
points = list(subsys_points)
ms = lines2subsystem(lines, ms, span=None, case=case)

ms = lines2subsystem(lines, points, ms, span=None, case=case)
ms.initialize()
ms.solveEquilibrium()
i += 1
Expand All @@ -1126,7 +1127,7 @@ def lines2ss(ms):

return ms

def lines2subsystem(lines,ms,span=None,case=0):
def lines2subsystem(lines, points, ms, span=None, case=0):
'''Takes a set of connected lines (in order from rA to rB) in a moorpy system and creates a subsystem equivalent.
The original set of lines are then removed from the moorpy system and replaced with the
subsystem.
Expand Down Expand Up @@ -1154,7 +1155,9 @@ def lines2subsystem(lines,ms,span=None,case=0):
from copy import deepcopy
# save a deepcopy of the line list to delete
originalList = deepcopy(lines)

print(originalList)
if any(type(ms.lineList[x])==Subsystem for x in originalList):
breakpoint()
# # check that all lines connect (all are sections of one full mooring line)
# for i in range(0,len(lines)):
# if i>0:
Expand Down Expand Up @@ -1244,12 +1247,13 @@ def lines2subsystem(lines,ms,span=None,case=0):
helpers.deleteLine(ms,lines[i],delpts)

# print('Replacing lines ',originalList,' with a subsystem appended to the end of the lineList ')
ss.staticSolve()
# append subsystem to ms
ms.lineList.append(ss)
ssNum = len(ms.lineList)
# attach subystem line to the end points
ms.pointList[pt[0]].attachLine(ssNum,0) # rA
ms.pointList[pt[-1]].attachLine(ssNum,1) # rB
ms.pointList[points[0]].attachLine(ssNum,0) # rA
ms.pointList[points[-1]].attachLine(ssNum,1) # rB

return(ms)

Expand Down Expand Up @@ -1366,7 +1370,33 @@ def deleteLine(ms,ln,delpts=0):
i -= 1
# increment i
i += 1


return(ms)

def deletePoint(ptnum,ms):

for i in range(len(ms.pointList)):
# reduce point.number
if ms.pointList[i].number > ptnum:
ms.pointList[i].number -= 1
# lower index of any body-attached points after deleted point, remove from any body-attached points
for i in range(len(ms.bodyList)):
ii = 0
while ii < len(ms.bodyList[i].attachedP):
if ms.bodyList[i].attachedP[ii] == ptnum:
# remove point from rel list
ms.bodyList[i].rPointRel.pop(ii)
# remove point from attached list
ms.bodyList[i].attachedP.pop(ii)
ii = ii - 1
elif ms.bodyList[i].attachedP[ii] > ptnum:
# reduce index by one
ms.bodyList[i].attachedP[ii] -= 1
ii += 1

# remove point
ms.pointList.pop(ptnum-1)

def subsystem2Line(ms,ssNum,nsegs=10):
'''Replace a subsystem with equivalent set of lines
Expand Down

0 comments on commit 4104d6e

Please sign in to comment.