Skip to content

Commit 949bca2

Browse files
committed
Unload updates, small mooring/platform fixes
-- unload: - cable appendage info (including connectors) now unloads if it's in the design dictionary of the dynamic cable - unload cable type info always (even if made with cableprops) - small bug fixes in platform and mooring - small update to calcDistance helper function
1 parent a8db9f8 commit 949bca2

File tree

4 files changed

+40
-27
lines changed

4 files changed

+40
-27
lines changed

famodel/helpers.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,7 +1520,7 @@ def compareDicts(d1, d2):
15201520
return(False)
15211521
return(True)
15221522

1523-
def calcMinimumDists(obj_list_A,obj_list_B=None, coords_list=None):
1523+
def calcMinimumDists(obj_list_A,obj_list_B=None, coords_list=None, ret_arg=False):
15241524
'''
15251525
Calculates and returns the minimum distance between 2 lists of objects.
15261526
@@ -1537,24 +1537,33 @@ def calcMinimumDists(obj_list_A,obj_list_B=None, coords_list=None):
15371537
-------
15381538
A2B : float
15391539
Minimum distance between the compared locations
1540+
ret_arg : list
1541+
A and (possibly) B indices in list that produced the lowest distance
15401542
15411543
'''
15421544
A2B=np.inf
15431545

15441546
if obj_list_B is not None:
1545-
for objA in obj_list_A:
1546-
for objB in obj_list_B:
1547+
for a, objA in enumerate(obj_list_A):
1548+
for b, objB in enumerate(obj_list_B):
15471549
if objA != objB:
15481550
dist = np.linalg.norm(np.array(objA.r[:2]) - np.array(objB.r[:2]))
1549-
A2B = min(A2B, dist)
1551+
if dist<A2B:
1552+
ret_arg = [a,b]
1553+
A2B = dist
15501554
elif coords_list!=None:
1551-
for objA in obj_list_A:
1555+
for a,objA in enumerate(obj_list_A):
15521556
dist = np.linalg.norm(objA.r[:2] - coords_list, axis=1)
1553-
A2B = min(A2B, np.min(dist))
1557+
if dist<A2B:
1558+
ret_arg = [a]
1559+
A2B = dist
15541560
else:
15551561
raise Exception('Either obj_list_B or coords_list must not be None')
1556-
1557-
return(A2B)
1562+
1563+
if ret_arg:
1564+
return(A2B, ret_arg)
1565+
else:
1566+
return(A2B)
15581567

15591568
def calcMaterialMasses(obj_list):
15601569
'''

famodel/mooring/mooring.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,10 @@ def getMG(mgDict, oldLine=None, ms=None, ss_number=None):
12301230
else:
12311231
ss = deepcopy(self.ss)
12321232
ss_number = ss.number
1233+
1234+
# update ms to the subsystem's sys if no ms given
1235+
if ms==None:
1236+
ms = ss.sys
12331237

12341238
if updateDepths:
12351239
# call getMG in a while loop until the settled depth matches the required change depth

famodel/platform/platform.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Platform(Node):
2020
Eventually will inherit from Node.
2121
'''
2222

23-
def __init__(self, id, r=[0,0,0], heading=0, mooring_headings=[60,180,300],rFair=None,zFair=None):
23+
def __init__(self, id, r=[0,0,0], heading=0,rFair=None,zFair=None):
2424
'''
2525
2626
Parameters
@@ -29,8 +29,6 @@ def __init__(self, id, r=[0,0,0], heading=0, mooring_headings=[60,180,300],rFair
2929
x and y coordinates [m].
3030
phi, float (optional)
3131
The heading of the object [deg].
32-
mooring_headings (optional)
33-
relative headings of mooring lines [deg].
3432
'''
3533
# Initialize as a node
3634
Node.__init__(self,id)
@@ -345,7 +343,7 @@ def getWatchCircle(self, plot=0, ang_spacing=45, RNAheight=150,
345343
moorings = [] # list of mooring lines attached
346344
cables = [] # list of cables attached
347345
dcs = []
348-
lBots = [0]*len(self.mooring_headings)
346+
lBots = [0]*len(self.getMoorings())
349347

350348
# find turbines, cables, and mooorings attached to platform
351349
moorings = self.getMoorings().values()

famodel/project.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4716,12 +4716,12 @@ def unload(self,file='project.yaml'):
47164716
ctA = sub.dd['cable_type']['A']
47174717
cKey = (ctw,ctA)
47184718
ctf = False
4719-
# check if made with getCableProps (then we can skip writing out cable type info)
4720-
if 'notes' in sub.dd['cable_type']:
4721-
if 'made with getCableProps' in sub.dd['cable_type']['notes']:
4722-
ctk = 'cableFamily'
4723-
ctn = 'static_cable_'+str(int(sub.voltage))
4724-
ctf = True
4719+
# # check if made with getCableProps (then we can skip writing out cable type info)
4720+
# if 'notes' in sub.dd['cable_type']:
4721+
# if 'made with getCableProps' in sub.dd['cable_type']['notes']:
4722+
# ctk = 'cableFamily'
4723+
# ctn = 'static_cable_'+str(int(sub.voltage))
4724+
# ctf = True
47254725

47264726
# create current cable config dictionary
47274727
if not ctf:
@@ -4764,11 +4764,11 @@ def unload(self,file='project.yaml'):
47644764
ctA = sub.dd['A']
47654765
cKey = (ctw,ctA)
47664766
ctf = False; ctk = 'cable_type'
4767-
# check if made with getCableProps (then we can skip writing out cable type info)
4768-
if 'notes' in sub.dd['cable_type']:
4769-
if 'made with getCableProps' in sub.dd['cable_type']['notes']:
4770-
ctn = ct+'_cable_'+str(int(sub.voltage))
4771-
ctf = True
4767+
# # check if made with getCableProps (then we can skip writing out cable type info)
4768+
# if 'notes' in sub.dd['cable_type']:
4769+
# if 'made with getCableProps' in sub.dd['cable_type']['notes']:
4770+
# ctn = ct+'_cable_'+str(int(sub.voltage))
4771+
# ctf = True
47724772
# check if cable type has already been written
47734773
if not ctf:
47744774
if not cKey in cUnique:
@@ -4778,8 +4778,13 @@ def unload(self,file='project.yaml'):
47784778
else:
47794779
cIdx = cUnique.index(cKey)
47804780
ctn = 'dyn_cab_'+str(cIdx)
4781-
# collect buoyancy sections info if applicable
4781+
# collect buoyancy sections (and appendages) info if applicable
47824782
bs = []
4783+
if 'appendages' in sub.dd:
4784+
for app in sub.dd['appendages']:
4785+
if not app['type'] in appendageTypes:
4786+
appendageTypes[app['type']] = app
4787+
bs.append({'type':app['type']})
47834788
if 'buoyancy_sections' in sub.dd:
47844789
for b in sub.dd['buoyancy_sections']:
47854790
btw = b['module_props']['w']; btv = b['module_props']['volume']
@@ -4794,9 +4799,6 @@ def unload(self,file='project.yaml'):
47944799
bs.append({'L_mid':b['L_mid'],'N_modules':b['N_modules'],
47954800
'spacing':b['spacing'],'V':b['module_props']['volume'],
47964801
'type':btn})
4797-
if 'appendages' in sub.dd:
4798-
for app in sub.dd['appendages']:
4799-
pass # UPDATE TO PULL OUT APPENDAGE INFO AND STORE
48004802

48014803
# grab joint info
48024804
if kk == 0 and len(cab.subcomponents)>1:

0 commit comments

Comments
 (0)