Skip to content

Commit c1691c2

Browse files
committed
edits to adjustMooring for multiple line sections
-adjustMooring now inputs a list of ints for i_line -all i_line segments are fixed to have the same length and the length is varied to acheive the horizontal force or pretension -small bug fix in head_adjust
1 parent c241c1a commit c1691c2

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

famodel/helpers.py

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def head_adjust(att,heading,rad_buff=np.radians(30),endA_dir=1, adj_dir=1):
250250
if heading<0:
251251
headnew = np.pi*2 + heading
252252
elif heading>2*np.pi:
253-
heading - 2*np.pi
253+
headnew = heading - 2*np.pi
254254
else:
255255
headnew = heading
256256
attheadings = [] # complete list of mooring headings to avoid, from all platforms
@@ -1270,7 +1270,7 @@ def configureAdjuster(mooring, adjuster=None, method='horizontal',
12701270
return(mooring)
12711271

12721272
def adjustMooring(mooring, method = 'horizontal', r=[0,0,0], project=None, target=1e6,
1273-
i_line = 0, slope = 0.58, display=False ):
1273+
i_line = [0], slope = 0.58, display=False ):
12741274
'''Custom function to adjust a mooring, called by
12751275
Mooring.adjust. Fairlead point should have already
12761276
been adjusted.
@@ -1282,13 +1282,13 @@ def adjustMooring(mooring, method = 'horizontal', r=[0,0,0], project=None, targe
12821282
----------
12831283
mooring : FAModel Mooring object
12841284
r : array
1285-
platform center location
1285+
platform center location (only used for pretension method)
12861286
project : FAModel Project object this is a part of.
1287-
Optional, default is None. This is a required input for the "pretension" option to correctly move the anchor position
1287+
This is a required input for the "pretension" option to correctly move the anchor position, not used in the 'horizontal method'
12881288
target_pretension : float
12891289
Total pretension OR horizontal force in N to target for the mooring line
1290-
i_line : int
1291-
Index of line section to adjust
1290+
i_line : list of ints
1291+
List of indexes of line section to adjust
12921292
slope: float
12931293
depth over span for baseline case (to match same geometric angle for 'pretension' option)
12941294
@@ -1338,19 +1338,22 @@ def adjustMooring(mooring, method = 'horizontal', r=[0,0,0], project=None, targe
13381338

13391339
# Estimate the correct line length to start with based on % of total length
13401340
L_tot = sum([line.L for line in ss.lineList])
1341-
initial_L_ratio = ss.lineList[i_line].L/L_tot
1342-
ss.lineList[i_line].setL(np.linalg.norm(mooring.rB - mooring.rA)*initial_L_ratio)
1341+
initial_L_ratio = ss.lineList[i_line[0]].L/L_tot
1342+
for i in i_line:
1343+
ss.lineList[i].setL(np.linalg.norm(mooring.rB - mooring.rA)*initial_L_ratio)
13431344

13441345
# Next we could adjust the line length/tension (if there's a subsystem)
13451346

13461347
def eval_func(X, args):
13471348
'''Tension evaluation function for different line lengths'''
1348-
ss.lineList[i_line].L = X[0] # set the first line section's length
1349+
for i in i_line:
1350+
ss.lineList[i].L = X[0] # set the first line section's length
13491351
ss.staticSolve(tol=0.0001) # solve the equilibrium of the subsystem
13501352
return np.array([ss.TB]), dict(status=1), False # return the end tension
13511353

13521354
# run dsolve2 solver to solve for the line length that matches the initial tension
1353-
X0 = [ss.lineList[i_line].L] # start with the current section length
1355+
for i in i_line:
1356+
X0 = [ss.lineList[i].L] # start with the current section length
13541357
if display:
13551358
L_final, T_final, _ = dsolve2(eval_func, X0, Ytarget=[target],
13561359
Xmin=[1], Xmax=[1.1*np.linalg.norm(ss.rB-ss.rA)],
@@ -1359,35 +1362,38 @@ def eval_func(X, args):
13591362
L_final, T_final, _ = dsolve2(eval_func, X0, Ytarget=[target],
13601363
Xmin=[1], Xmax=[1.1*np.linalg.norm(ss.rB-ss.rA)],
13611364
dX_last=[1], tol=[0.01], maxIter=50, stepfac=4)
1362-
ss.lineList[i_line].L = L_final[0]
1363-
sec = mooring.getSubcomponent(i_line)
1364-
sec['L'] = L_final[0]
1365+
for i in i_line:
1366+
ss.lineList[i].L = L_final[0]
1367+
sec = mooring.getSubcomponent(i)
1368+
sec['L'] = L_final[0]
13651369
mooring.dd['span'] = span
13661370
mooring.span = span
13671371

13681372
elif method == 'horizontal':
13691373
def func_TH_L(X, args):
13701374
'''Apply specified section L, return the horizontal pretension error.'''
1371-
ss.lineList[i_line].setL(X[0])
1375+
for i in i_line:
1376+
ss.lineList[i].setL(X[0])
13721377
ss.staticSolve()
13731378
#Fx is the horizontal pretension
13741379
Fx = np.linalg.norm([ss.fB_L[0], ss.fB_L[1]])
13751380

13761381
return np.array([Fx - target]), dict(status=1) , False
13771382

1378-
X0 = [ss.lineList[i_line].L]
1383+
X0 = [ss.lineList[i_line[0]].L]
13791384
if display:
13801385
x, y, info = dsolve2(func_TH_L, X0, tol=[0.01],
13811386
args=dict(direction='horizontal'),
13821387
Xmin=[10], Xmax=[2000], dX_last=[10],
1383-
maxIter=50, stepfac=4, display = 5)
1388+
maxIter=100, stepfac=4, display = 5)
13841389
else:
13851390
x, y, info = dsolve2(func_TH_L, X0, tol=[0.01],
13861391
args=dict(direction='horizontal'),
13871392
Xmin=[10], Xmax=[2000], dX_last=[10],
1388-
maxIter=50, stepfac=4)
1393+
maxIter=100, stepfac=4)
13891394
# update design dictionary L
1390-
mooring.setSectionLength(ss.lineList[i_line].L,i_line)
1395+
for i in i_line:
1396+
mooring.setSectionLength(ss.lineList[i].L,i)
13911397

13921398
else:
13931399
print('Invalid method. Must be either pretension or horizontal')

0 commit comments

Comments
 (0)