@@ -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
963967def 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
994998def 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+
13121316def 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
13301337def getFromDict (dict , key , shape = 0 , dtype = float , default = None , index = None ):
13311338 '''
0 commit comments