Skip to content

Commit e0213b6

Browse files
committed
Add option to switch sides in cable routing
1 parent f50ec16 commit e0213b6

File tree

2 files changed

+36
-16
lines changed

2 files changed

+36
-16
lines changed

famodel/helpers.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def check_headings(m_headings,c_heading,rad_buff):
223223
return([])
224224

225225

226-
def head_adjust(att,heading,rad_buff=np.radians(30),endA_dir=1):
226+
def head_adjust(att,heading,rad_buff=np.radians(30),endA_dir=1, adj_dir=1):
227227
'''
228228
function to adjust heading of cable based on angle buffer from mooring lines
229229
@@ -238,6 +238,10 @@ def head_adjust(att,heading,rad_buff=np.radians(30),endA_dir=1):
238238
endA_dir : float, optional
239239
Either 1 or -1, controls sign of new heading for end B. Only altered to -1 if dynamic
240240
cable from end A will get close to end B moorings. Default is 1.
241+
adj_dir : float, optional
242+
Either 1 or -1, default is 1. If -1, adjusts direction heading is altered
243+
to avoid mooring lines, can be used if that heading direction is more natural.
244+
This is a manual input to the main function adjusting cables.
241245
242246
Returns
243247
-------
@@ -269,7 +273,7 @@ def head_adjust(att,heading,rad_buff=np.radians(30),endA_dir=1):
269273
# if the headings interfere, adjust them by angle buffer
270274
for mhead in interfere_h:
271275
ang_diff_dir = np.sign(headnew - mhead) if headnew != mhead else 1
272-
headnew = mhead - rad_buff*endA_dir*ang_diff_dir #headnew + np.sign(ang_diff)*(rad_buff - abs(ang_diff))*endA_dir
276+
headnew = mhead - adj_dir*rad_buff*endA_dir*ang_diff_dir #headnew + np.sign(ang_diff)*(rad_buff - abs(ang_diff))*endA_dir
273277
interfere_hi = check_headings(attheadings,headnew,rad_buff)
274278
for i in interfere_hi:
275279
# try rotating other way
@@ -961,7 +965,7 @@ def attachFairleads(moor, end, platform, fair_ID_start=None, fair_ID=None, fair_
961965
return(fairs)
962966

963967
def calc_heading(pointA, pointB):
964-
'''calculate a heading from points, if pointA or pointB is a list of points,
968+
'''calculate a compass heading from points, if pointA or pointB is a list of points,
965969
the average of those points will be used for that end'''
966970
# calculate the midpoint of the point(s) on each end first
967971
pointAmid = calc_midpoint(pointA)
@@ -992,7 +996,7 @@ def calc_midpoint(point):
992996

993997

994998
def route_around_anchors(proj, anchor=True, cable=True, padding=50):
995-
999+
'''check if static cables hit anchor buffer, if so reroute cables around anchors'''
9961000
# make anchor buffers with 50m radius
9971001
if anchor:
9981002
anchor_buffs = []
@@ -1308,24 +1312,27 @@ def gothroughlist(dat):
13081312
# return cleaned dictionary
13091313
return(info)
13101314

1311-
'''
1315+
13121316
def createRAFTDict(project):
1317+
from famodel.turbine.turbine import Turbine
13131318
# Create a RAFT dictionary from a project class to create RAFT model
1314-
rd = {'keys':['ID', 'turbineID', 'platformID', 'mooringID', 'x_location', 'y_location'],
1315-
'data':[]}
1319+
rd = {'array':{'keys':['ID', 'turbineID', 'platformID', 'mooringID', 'x_location', 'y_location', 'heading_adjust'],
1320+
'data':[]}}
1321+
turb = 0
13161322
for pf in project.platformList.values():
13171323
for att in pf.attachments.values():
13181324
if isinstance(att['obj'],Turbine):
1319-
turb = att['obj']
1325+
turb = att['obj'].dd['type']
13201326
break
1321-
rd.append(pf.id, turb.dd['type'], pf.dd['type'], 0, pf.r[0], pf.r[1])
1327+
rd['array']['data'].append([pf.id, turb, pf.dd['type'], 0, pf.r[0], pf.r[1],np.degrees(pf.phi)])
13221328
rd['site'] = {'water_depth':project.depth,'rho_water':project.rho_water,'rho_air':project.rho_air,'mu_air':project.mu_air}
13231329
rd['site']['shearExp'] = .12
13241330

1325-
for tt in project.turbineType
1331+
rd['turbines'] = project.turbineTypes
1332+
rd['platforms'] = project.platformTypes
13261333

13271334
return rd
1328-
'''
1335+
13291336

13301337
def getFromDict(dict, key, shape=0, dtype=float, default=None, index=None):
13311338
'''

famodel/project.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,7 +1942,7 @@ def addCablesConnections(self,connDict,cableType_def='dynamic_cable_66',oss=Fals
19421942
substation_r=[None],ss_id=200,id_method='location',
19431943
keep_old_cables=False, connect_ss=True,
19441944
cableConfig=None, configType=0,heading_buffer=30,
1945-
route_anchors=True):
1945+
route_anchors=True, adj_dir=1):
19461946
'''Adds cables and connects them to existing platforms/substations based on info in connDict
19471947
Designed to work with cable optimization output designed by Michael Biglu
19481948
@@ -2098,11 +2098,24 @@ def addCablesConnections(self,connDict,cableType_def='dynamic_cable_66',oss=Fals
20982098
# consider mooring headings from both ends if close enough
20992099
pfsp = np.linalg.norm(attA.r-attB.r)
21002100
if pfsp-2*attA.rFair < msp+dc0s:
2101-
headingA = head_adjust([attA,attB],headingA,rad_buff=rad_buff)
2102-
headingB = head_adjust([attB,attA],headingB,rad_buff=rad_buff,endA_dir=-1)
2101+
headingA = head_adjust([attA,attB],
2102+
headingA,
2103+
rad_buff=rad_buff,
2104+
adj_dir=adj_dir)
2105+
headingB = head_adjust([attB,attA],
2106+
headingB,
2107+
rad_buff=rad_buff,
2108+
endA_dir=-1,
2109+
adj_dir=adj_dir)
21032110
else:
2104-
headingA = head_adjust([attA],headingA,rad_buff=rad_buff)
2105-
headingB = head_adjust([attB],headingB,rad_buff=rad_buff)
2111+
headingA = head_adjust([attA],
2112+
headingA,
2113+
rad_buff=rad_buff,
2114+
adj_dir=adj_dir)
2115+
headingB = head_adjust([attB],
2116+
headingB,
2117+
rad_buff=rad_buff,
2118+
adj_dir=adj_dir)
21062119

21072120
heads = [headingA,headingB]
21082121
# reposition cable

0 commit comments

Comments
 (0)